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
437 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,569 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
262 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,314 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
393 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
4,987 views
0 votes
0 answers

JavaScript or jQuery "Are you sure?" dialog for <A> link?

I have a link in my HTML: <a ...READ MORE

Jul 26, 2022 in Web Development by gaurav
• 23,260 points
246 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,670 points
9,843 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
4,613 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,094 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,510 points
1,004 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