Solved

Get value of id using jQuery

Posted on 2016-08-12
2
49 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

914 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

20 Experts available now in Live!

Get 1:1 Help Now