0){ // element...">

How to check if #id exists with phpquery? .Length?

How to check if #id exists with phpquery?

JQuery

if ($("#mydiv").length > 0){
    // element exist
}

phpquery To check if the .class class works, use → hasClass.

+3
source share
2 answers
if(pq("#mydiv")->length) {
  // element exists
}
+4
source

perhaps this is how you ask about it, but isn't this a case of mixing identifiers and classes? # is looking for an identifier, if you need an array with classes, you need $ (".mydiv")...

0
source

All Articles