如何在wordpress中编写jquery
我试图在wordpress divi代码模块中使用jQuery获取div的值并在url中传递该值 我在控制台中遇到未定义的错误 这是我的jquery代码如何在wordpress中编写jquery,jquery,wordpress,Jquery,Wordpress,我试图在wordpress divi代码模块中使用jQuery获取div的值并在url中传递该值 我在控制台中遇到未定义的错误 这是我的jquery代码 jQuery(".xsub").click(function(){ console.log(jQuery("div#user-region").val()); var xst = document.getElementById('user-region'); console.log(xst.value); window.location.hr
jQuery(".xsub").click(function(){
console.log(jQuery("div#user-region").val());
var xst = document.getElementById('user-region');
console.log(xst.value);
window.location.href ='https://jobplace360.com/hud/hud-listings/?'+xst;
});
当新页面打开时,我进入url[object%20htmldevelment],请尝试以下代码:
var $=jQuery.noConflict();
$(document).ready(function(){
// Handler for .ready() called.
$(".xsub").click(function(){
console.log($("div#user-region").val());
var xst = $('#user-region').html();
console.log(xst);
window.location.href ='https://jobplace360.com/hud/hud-listings/?'+xst;
});
});
请尝试以下代码:
var $=jQuery.noConflict();
$(document).ready(function(){
// Handler for .ready() called.
$(".xsub").click(function(){
console.log($("div#user-region").val());
var xst = $('#user-region').html();
console.log(xst);
window.location.href ='https://jobplace360.com/hud/hud-listings/?'+xst;
});
});
您需要使用innerHtml
var xst = document.getElementById('user-region').innerHtml;
您需要使用innerHtml
var xst = document.getElementById('user-region').innerHtml;
无法正常工作未捕获的TypeError:$不是HTMLInputElement上的函数。((索引):284)在HTMLInputElement.dispatch(jquery.js?ver=1.12.4:3)在HTMLInputElement.r.handle(jquery.js?ver=1.12.4:3)(匿名)@(索引):284 dispatch@jquery.js?ver=1.12.4:3 r.handle@jquery.js?ver=1.12.4:3@TayyabGulsherVohra添加第1行是否解决了问题?未捕获类型错误:$不是HTMLInputElement的函数。((索引):284)在HTMLInputElement.dispatch(jquery.js?ver=1.12.4:3)在HTMLInputElement.r.handle(jquery.js?ver=1.12.4:3)(匿名)@(索引):284 dispatch@jquery.js?ver=1.12.4:3 r.handle@jquery.js?ver=1.12.4:3@TayyabGulsherVohra添加第1行是否解决了问题?