jquery - How to select deeper elements created dynamically? -


i created elements inside ajax script :

<?php ... foreach ($rows $row) {     $no_rows = false;     $img = ($row["img_fichier"] === null ? http_img.'default_article.jpg' : http_img.$row["img_fichier"]);     $msg .= '<div id="tile_article_'.$row["article_id"].'" data-pk="'.$row["article_id"].'" class="tile fg-black" style="text-align:center;">                 <div class="tile-content">                     <label class="input-control checkbox small-check">                         <input class="article" id="article_'.$row["article_id"].'" name="article_'.$row["article_id"].'" type="checkbox" value="'.$row["article_id"].'" />                         <span class="check"></span>                         <span class="caption">'.$row["article_lib"].'</span>                     </label>                     <input type="text" id="qtecmd_'.$row["article_id"].'" name="qtecmd_'.$row["article_id"].'" placeholder="'._gettext('souscommande.qte.placeholder').'" class="numeric qtecmd" />                     <div class="image-container">                         <div class="frame"><img src="'.$img.'" /></div>                     </div>                 </div>             </div>'; } ... echo $msg; } ?> 

the responsetext of ajax inserted div :

<div id="cmds"></div> 

in $(document).ready call ajax because there $_get parameters gotten page :

<script> function loaddata(page) {          var cols = "article_id,article_lib,img_fichier";          var tabs = "article left join image on a.img_id = i.img_id";          var = "";         if ($("#famille_article").val() != "") {             if (where == "")                 += "where a.fam_arti_code = '"+$("#famille_article").val()+"'";             else                 += " , a.fam_arti_code = '"+$("#famille_article").val()+"'";         }         if ($("#categorie_article").val() != "") {             if (where == "")                 += "where a.cat_arti_code = '"+$("#categorie_article").val()+"'";             else                 += " , a.cat_arti_code = '"+$("#categorie_article").val()+"'";         }          var ret = $.ajax ({                             type: "post",                             async: false,                             data: "nbr="+$("#nbr").val()+"&page="+page+"&cols="+cols+"&tab="+tabs+"&where="+where,                             url: "../../restaurantcommande/ajaxloadarticles"                         }).responsetext;         $("#cmds").html(ret);     } $(document).ready(function() {                 loaddata(1);         ... } </script> 

in $(document).ready want hide elements having class qtecmd. how ?

you can after insertion :

$("#cmds").html(ret).find('.qtecmd').hide(); 

if want directly in $(document).ready, can :

$(document).ready(function() {             loaddata(1);     $('#cmds').find('.qtecmd').hide(); } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -