javascript - How to select multiples HTML elments with jquery -
I want to use jquery with all elements that are active with id = result-XX (class = ... Active).
The HTML page contains:
& lt; Li id = "result-1" class = "list-group-item hover active" & gt; & Lt; / Li & gt; & Lt; Li id = "result-2" class = "list-group-item hover" & gt; & Lt; / Li & gt; & Lt; Li id = "result-3" class = "list-group-item hover" & gt; & Lt; / Li & gt; I have tried the following (to select only the list of results), but it does not work:
console.log ( "Result:" + $ ('Li [id ^ = "result-1"') length). Console.log ("Results:" + $ ("li: in ('result -')"). Length); Console.log ("Result:" + $ ("li [id ~ = 'result -']"). Length); Then, we just need to get active ones.
Should work first, but your selector is wrong $ ('li = id = 'Result -'] ') . You can use $ ('li [id ^ =' result- "] '). To minimize the filter (". Active ") / Code> ones, like Miscellaneous Elements, Active Elements; Element = $ ('Li [id =' 'Results- "]'); Active Elements = Elements. Filter ("Active"); View
Comments
Post a Comment