jQuery(document).ready';当我提交表格时,我不会运行
我编写了一些jquery,当某个页面加载时运行,这很好。问题是,当我提交表单时,它也会运行,这会把提交搞砸 有没有办法绕过这个问题 我的表格: 和jquery文件: 谢谢 以下是我认为相关的代码部分:jQuery(document).ready';当我提交表格时,我不会运行,jquery,wordpress,forms,Jquery,Wordpress,Forms,我编写了一些jquery,当某个页面加载时运行,这很好。问题是,当我提交表单时,它也会运行,这会把提交搞砸 有没有办法绕过这个问题 我的表格: 和jquery文件: 谢谢 以下是我认为相关的代码部分: // CUSTOM JAVASCRIPT FUNCTIONS jQuery(document).ready(function () { tripFilter = function () { var tripClass = '.hotel-trip select',
// CUSTOM JAVASCRIPT FUNCTIONS
jQuery(document).ready(function () {
tripFilter = function () {
var tripClass = '.hotel-trip select',
hotelClass = '.hotel-name select',
unusedClass = '.unused-options select';
var tripSelect = jQuery(tripClass),
trip = tripSelect.val(),
hotelSelect = tripSelect.parents('form').find(hotelClass);
if (trip !== undefined && trip !== "") {
if (trip === "none"){
jQuery(hotelClass+" > option").each(function() {
jQuery(this).clone().appendTo(unusedClass);
jQuery(this).remove();
});
} else {
tripnum = trip.match(/JWRP (\d*)/)[1];
jQuery(unusedClass+" > option").each(function() {
jQuery(this).clone().appendTo(hotelClass);
jQuery(this).remove();
});
jQuery(hotelClass+" > option").each(function() {
hotelMatch = jQuery(this).val().match(/(\d*) /);
if(jQuery(this).val() != "Other|"){
if (hotelMatch === null || hotelMatch[1] != tripnum){
jQuery(this).clone().appendTo(unusedClass);
jQuery(this).remove();
};
}else{
jQuery(this).appendTo(hotelClass);
};
});
jQuery(hotelClass + 'option[value="Other|"]').insertAfter(hotelClass + 'option:last-child');
jQuery(hotelClass).val(jQuery(hotelClass + "option:first").val());
}
}
}
jQuery('.hotel-trip select').change(function(){
tripFilter();
});
tripFilter();
});
请在此处添加有意义的代码和问题描述。不要只链接到需要修复的站点——否则,一旦问题解决,这个问题将对未来的访问者失去任何价值。发布一个能证明你的问题的帖子会帮助你得到更好的答案。有关更多信息,请参阅“谢谢!”!并非所有jquery都必须包装在
$(document).ready()函数中。只需编写一个普通的js函数并将代码放在那里,但正如j08691所说,如果您这样做,您需要将代码放在问题中,不要链接它。谢谢!它看起来像是把它修好了;我现在要再检查一遍。不,它还是不起作用。还有其他想法吗?谢谢