• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

What's the jQuery to find this attribute?

What's the jQuery to find all elements where I set the following?


$("#anyElement").attr("myFlag",1")
0
newbieweb
Asked:
newbieweb
  • 3
  • 2
3 Solutions
 
danbaugherCommented:
The string you provided has a syntax error. To find objects in the dom with the attribute myFlag set to 1 try, $('*[myFlag=1]')
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks. What's the syntax error?
0
 
newbiewebSr. Software EngineerAuthor Commented:
Also, what's the syntax if I wanted all elements with any value for myFlag?

PS I see the syntax error: thanks.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
danbaugherCommented:
$('[myflag]')
0
 
Kiran SonawaneProject LeadCommented:
If you want to check the attribute then

if($("#anyElement").attr("myFlag") == "1")
 // your code
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now