Solved

What's the jQuery to find this attribute?

Posted on 2011-09-26
6
223 Views
Last Modified: 2012-05-12
What's the jQuery to find all elements where I set the following?


$("#anyElement").attr("myFlag",1")
0
Comment
Question by:newbieweb
  • 3
  • 2
6 Comments
 
LVL 1

Assisted Solution

by:danbaugher
danbaugher earned 333 total points
ID: 36689824
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
 

Author Comment

by:newbieweb
ID: 36691422
Thanks. What's the syntax error?
0
 

Author Comment

by:newbieweb
ID: 36692693
Also, what's the syntax if I wanted all elements with any value for myFlag?

PS I see the syntax error: thanks.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Assisted Solution

by:danbaugher
danbaugher earned 333 total points
ID: 36704136
$('[myflag]')
0
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 167 total points
ID: 36706418
If you want to check the attribute then

if($("#anyElement").attr("myFlag") == "1")
 // your code
0
 

Author Closing Comment

by:newbieweb
ID: 36708971
Thanks!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now