JS用于按钮,Jquery选择器

JS用于按钮,Jquery选择器,jquery,html,Jquery,Html,我在浏览我页面的示例时,遇到了一个奇怪的JQuery选择器。你们能解释一下它是如何工作的吗?我能用它来选择HTML中具有唯一索引的ID吗 //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

我在浏览我页面的示例时,遇到了一个奇怪的JQuery选择器。你们能解释一下它是如何工作的吗?我能用它来选择HTML中具有唯一索引的ID吗

//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+ "\" 
“div[id^='myModal']”表示所有以“myModal”开头的id元素的div,例如myModal1、myModal2等/……。

a[href^=“https”]这表示选择href属性值以“https”开头的每个元素 您可以在这个链接中找到选择器的含义

关于
id=\“Modals\”+index+“\”
index是变量,您可以像下面的代码一样将其用于id

ID="Modals_"+index
$("p").attr("id",ID)