php - Regarding Jquery addition of onclick attribute dynamically -


on clicking link below, want change onclick function onclick="linksubcategory(1, \'people\', \'1\', \'peoplelink\');" changing third attribute 1 0.

<a href="#" id="peoplelink" onclick="linksubcategory(1, \'people\', \'0\', \'peoplelink\');" style="display: inline-block;"><img src="images/icons/group.png"></a> 

for above requirement using code below not working. kindly suggest me way achieve requirement.

function linksubcategory(divid, divname, chkval, linkid) { $("#"+linkid).removeattr("onclick");         $("#"+linkid).attr("onclick", "linksubcategory("+divid+", '"+divname+"', '1', '"+ linkid +"')");} 

the way see things:

<a href="#" id="peoplelink" data-divid="1" data-divname="people" data-chkval="0" class="linksubcategory" ></a> 

jquery

$('.linksubcategory').click(function(){    linksubcategory($(this).data('divid'), $(this).data('divname'), $(this).data('chkval'), this.id);    $(this).data('chkval',1); }); 

this way don't need change event handler. cause imo , changing handler means want radically change way works, here need change parameter.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -