jQuery attr('onclick')

前端 未结 4 2014
Happy的楠姐
Happy的楠姐 2020-12-15 03:45

I\'am trying to change \"onclick\" attribute in jQuery but it doesn\'t change, here is my code:

$(\'#stop\').click(function() {
     $(\'next\').attr(\'oncli         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 04:14

    The easyest way is to change .attr() function to a javascript function .setAttribute()

    $('#stop').click(function() {
        $('next')[0].setAttribute('onclick','stopMoving()');
    }
    

提交回复
热议问题