Getting a jQuery selector for an element

0 votes

In psuedo code, this is what I want.

var selector = $(this).cssSelectorAsString(); // Made up method...
// selector is now something like: "html>body>ul>li>img[3]"
var element = $(selector);

The reason is that I need to pass this off to an external environment, where a string is my only way to exchange data. This external environment then needs to send back a result, along with what element to update. So I need to be able to serialize a unique CSS selector for every element on the page.

I noticed jquery has a selector method, but it does not appear to work in this context. It only works if the object was created with a selector. It does not work if the object was created with an HTML node object.

Aug 11, 2022 in Web Development by gaurav
• 23,260 points
691 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Web Development

0 votes
0 answers

jQuery Validate plugin not validating an element that's not a form input

I need to validate with jQuery Validation ...READ MORE

Aug 18, 2022 in Web Development by gaurav
• 23,260 points
1,841 views
0 votes
0 answers

jQuery Validate plugin not validating an element that's not a form input

I need to validate with jQuery Validation ...READ MORE

Aug 19, 2022 in Web Development by gaurav
• 23,260 points
507 views
0 votes
1 answer

How can you add a class to an element using jQuery?

For adding a class to an element ...READ MORE

answered Nov 13 in Web Development by kavya
31 views
0 votes
0 answers

If/else else if in Jquery for a condition

I am having a set of text ...READ MORE

Jul 1, 2022 in Web Development by gaurav
• 23,260 points
2,804 views
0 votes
0 answers

Scroll to an element with jQuery

I have this input element: <input type="text" class="textfield" ...READ MORE

Jul 1, 2022 in Web Development by gaurav
• 23,260 points
503 views
0 votes
0 answers

how to get values of columns for a selected row through jQuery

here i am trying to fetch values ...READ MORE

Jul 1, 2022 in Web Development by gaurav
• 23,260 points
5,431 views
0 votes
1 answer

jQuery find all elements with class beneath parent, even in children elements

Remove > from your select $(".parent .searchEl"). You can use the .find() method ...READ MORE

answered Jun 7, 2022 in JQuery by Edureka
• 13,690 points
10,733 views
0 votes
0 answers

jQuery find and replace string

I have somewhere on website a specific ...READ MORE

Jun 10, 2022 in JQuery by gaurav
• 23,260 points
5,510 views
0 votes
0 answers

Jquery: Get each image src

I have a series of images each ...READ MORE

Aug 11, 2022 in Web Development by gaurav
• 23,260 points
3,697 views
0 votes
1 answer

What is jQuery?

Hey, jQuery is a fast and concise JavaScript ...READ MORE

answered Feb 14, 2020 in JQuery by kartik
• 37,520 points
1,315 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP