JQuery Selector Multiple Attribute Selector

From CoderLearner
Jump to: navigation, search

Description

Match elements that match all the specified attribute filters.

Syntax

$('input[type="checkbox"][name="car1"]')
$('input[id][class~="cee"]')
$('input[name="lname"][id="mlastname"]')

Example 1

<!DOCTYPE html>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Select</title>
      <script 
         type="text/javascript" 
         src="/lib/jquery-1.7.2.min.js">				 
      </script>
      <script>
         $().ready(function() {
            $('input[type="checkbox"][name="car1"]').attr("disabled","disabled");
            $('input[id][class~="cee"]').val("Multiple ***");
            $('input[name="lname"][id="mlastname"]').val("******SOME**");
         });
      </script>
   </head>
   <body> 
      <form>
         <input type="checkbox" name="car0" id="car0" value="BMW"/>
         <input type="checkbox" name="car1" id="car1" value="Honda Accord"/>
         <input type="checkbox" name="car2" id="car2" value="Toyota Camery"/>
         <input type="checkbox" name="car3" id="car3" value="Ford Egde"/>
         <br/>
         <input type="text" name="fname" id="mfirstname" class="cee"/><br/>
         <input type="text" name="lname" id="mlastname" class="cll"/>
      </form>
   </body>
</html>

Try It