Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有标签类的元素
<li><a><span class='label'>$element</span></a></li>
我希望能够运行loadStuffonclick。如何获取单击元素的值以传递,例如:
loadStuff
$(".label").click(loadStuff(valueOfClickedElement));
当您说价值时,我假设您的意思是跨度的文本..
如果是这样,那么试试下面,
$(".label").click(function () { loadStuff($(this).text()); });
$(".label").click(function() { loadStuff($(this).text()); });