0

I was browsing for examples for my page and ran across a weird JQuery selector. Can any of you explain how does it work, and can I use it to select ID's in HTML which have unique indexing.

//The selector which I don't know how it works
//what is "^" exactly for?
"div[id^='myModal']"



//How Jquery for me dyanimcally creates HTML with Array elements and indexes ID's
 id=\"Modals_" +index+ "\" 

2 Answers 2

1

a[href^="https"] this mean is Selects every element whose href attribute value begins with "https" you can find meaning of selector in this link https://www.w3schools.com/cssref/css_selectors.asp

about id=\"Modals_" +index+ "\"index is variable and you can use this for ID like this code

ID="Modals_"+index
$("p").attr("id",ID)
Sign up to request clarification or add additional context in comments.

Comments

0

"div[id^='myModal']" it means that all the div's with starting of ID element with "myModal" for exmple myModal1, myModal2 etc/...............

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.