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

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -