jquery selection condition

<!DOCTYPE html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<div id="myparent">

<div id=”another_thing”>


   function ($) {
      $("li").filter("[class*=c]").css("color", "red");
         function (i) {return i!=5;}
       ).css("color", "red");
   function ($) {
       jq = $("ul");
       $("div").has(jq).css("color", "red");// seems like a more elegant selecting method.

// this will return 9
    function ($) {
         l = $("div").find("li").length;

function ($) {
     $("li").closest("[class=parent]").css("list-style", "none");// this will remove the list style
      $("li").parentsUntil("[id=myparent]").css("margin-top", "50px");// this will put margin on both divs
  function ($) {
    $("li").closest("[class=parent]").css("list-style", "none");
    $("li").parentsUntil("[id=myparent]").css("margin-top", "50px");
    $("li").next("[class=c]").css("color", "blue");
    $("li[class=d]").nextUntil("[class=f]").css("color", "silver");
the call to prepend has the effect of moving the elements rather than adding them twice. 
To address this issue, you need to create copies of the elements you want to insert by 
using the clone method. Listing 7-8 shows the revised script. 
Listing 7-8. Cloning Elements So They Can Be Added to the Document More Than Once 
<script type="text/javascript"> 
    $(document).ready(function() {
          var orchidElems = $("<div class='dcell'/>")
                            .append("<img src='orchid.png'/>") 
                            .append("<label for='orchid'>Orchid:</label>")
                            .append("<input name='orchid' value='0' required />"); 
           var newElems = $("<div class='dcell'/>") 
                            .append("<img src='lily.png'/>") 
                            .append("<label for='lily'>Lily:</label>") 
                            .append("<input name='lily' value='0' required />")
           newElems.css("border", "thick solid red");

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s