Answers for "get selector from jquery object"

6

jquery select by element

<p id="test" class="hello">Hello</p>

<script>
  //Hide all elements "p"
  $("p").hide();
  //Hide id="Test"
  $("#test").hide();
  //Hide all class="hello"
  $(".hello").hide();
  //Hide all "p" with class="hello"
  $("p.test").hide();
</script>
Posted by: Guest on October-19-2021
1

jquery from object to queryselector

$( "#foo" )[ 0 ]; // Equivalent to document.getElementById( "foo" ) or document.querySelector('#foo')

$( "#foo" ).get( 0 ); // Identical to above, only slower.
Posted by: Guest on October-01-2020

Browse Popular Code Answers by Language