I would like to use Jquery to add a class to \"li\" element that contains a \"span\" element with a html/val equal to zero.
For Example if my code looks like this:
You can match the element with filter(), then get its parent with parent(): $("li > span.num").filter(function() { return $(this).text() === "0"; }).parent().addClass("disabled"); 0 讨论(0) 查看其它5个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复
with parent(): $("li > span.num").filter(function() { return $(this).text() === "0"; }).parent().addClass("disabled"); 0 讨论(0) 查看其它5个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复
$("li > span.num").filter(function() { return $(this).text() === "0"; }).parent().addClass("disabled");