[英]jQuery find element with class name and attribute value
Haven't come up with much as far as documentation goes. 就文档而言,还没有提出太多建议。 How do I find an element with a particular class name that also has a specified attribute value.?
如何找到具有特定类名且具有指定属性值的元素?
function go_to_page(page){
$('.page_link[longdesc=page]').addClass('.active_page');
}
I got the example from here . 我从这里得到了例子。 Tried testing it myself and it didn't seem to work.
我自己尝试过测试,但似乎没有用。
function go_to_page(page){
$('.page_link[longdesc=' + page + ']').addClass('active_page');
}
You have some errors in your syntax, try: 您的语法有误,请尝试:
function go_to_page(page){
$('.page_link[longdesc='+page+']').addClass('active_page');
}
classes normally don't start with a dot (only in the selector not the name) 类通常不以点开头(仅在选择器中而不是名称中)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.