Solved

Get value of id using jQuery

Posted on 2016-08-12
2
40 Views
Last Modified: 2016-08-12
I'm attempting to create a GreaseMonkey script that will return the value of id in the following html:
<div class="foo">
                <div class="bar" id="random1234"></div>
</div>

Open in new window

In the above example random1234 would be returned.
0
Comment
Question by:Tom
2 Comments
 
LVL 6

Accepted Solution

by:
Mukesh Yadav earned 500 total points
ID: 41753840
Try this ;)
<script>
$(function(){
  console.log($('div.foo div.bar').attr('id'));
});
</script>

Open in new window

0
 

Author Comment

by:Tom
ID: 41753842
Excellent!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 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

15 Experts available now in Live!

Get 1:1 Help Now