我将 jqtransform 用于我的表单字段。当我将动态字段添加到表单时,jqtransform 不会应用于新字段。请查看示例代码,
$(function(){
$('form#js_greatdeals_form').jqTransform();
$('#js_greatdeals_form div.jqTransformSelectWrapper ul li a').click(function(){
var value = $(this).parent().index();
$("#select_cntry").attr('selectedIndex', value);
var countryiso = $("#select_cntry").val();
if(countryiso == 1) {
var content = '<select name="state" id="state"><option value="s1">State1</option><option value="s2">State2</option></select>';
$('#newselect').html(content);
$('select#state').jqTransform(); //Newly added
}
});
});
我的形式是,
<form id="js_greatdeals_form" name="js_greatdeals_form" method="post">
<select id="select_cntry">
<option selected="selected">select</option>
<option value="1">Country1</option>
<option value="2">Country2</option>
</select>
<div id="newselect"></div>
</form>
我尝试了针对问题给出的答案[请参阅评论行“新添加”]。但该解决方案也不适用于我。请只做那些需要的。谢谢