$('.more').click(function test(id) {
$('#MoreFriendInfo'+id).toggle();
});
I made this, function test(id), now how should i make the link right in html/php in order to grab the id?
I tried this, but it doesnt work:
<a class='more' href="javascript:void(0);" onclick='test(<?php echo $showInfo["bID"]; ?>)'>mer</a>
In firebug i get “test isnt defined”
In all of these, we’re removing the
onclickfrom the markup:You can use a data attribute, like this:
Then grab it in your
.click()handler, like this:Alternatively if it’s in another container forget the IDs and find it relatively, for example if the markup was like this:
You could do it like this:
(In this case you can actually use
.siblings(), but it’s meant to be a more general approach)