如何使用JQuery定位变量的子项

时间:2011-06-15 11:14:00

标签: jquery variables target

如何定位 post_ad_cloned的输入子项?

var post_ad = $('.duplicate_name'); 
var post_ad_cloned = post_ad.clone().removeClass('duplicate_name').appendTo('#sss').show();
$("post_ad_cloned input").css('color', 'red'); 

1 个答案:

答案 0 :(得分:5)

var post_ad = $('.duplicate_name'); 
var post_ad_cloned = post_ad.clone().removeClass('duplicate_name').appendTo('#sss').show();
$("input", post_ad_cloned).css('color', 'red'); 

或:

var post_ad = $('.duplicate_name'); 
var post_ad_cloned = post_ad.clone()
  .removeClass('duplicate_name')
  .appendTo('#sss')
  .show()
  .children('input')
    .css('color', 'red');