Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在wordpress中编写jquery_Jquery_Wordpress - Fatal编程技术网

如何在wordpress中编写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

我试图在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.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行是否解决了问题?