jquery - 如何在wordpress中编写jquery
问题描述
我正在尝试在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%20HTMLDivElement]
解决方案
试试这个代码:
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;
});
});
推荐阅读
- clips - CLIPS 如何根据 deftemplate 关系槽查找事实
- django - Django 2.2:为多个数据库创建模型
- azure-machine-learning-service - 数据漂移笔记本的问题
- javascript - 选择所有具有名称属性的输入包含子字符串 - jQuery
- sql-server - 如何防止 NULL 在 Dataframe 中导致错误的数据类型?
- java - javax.servlet.http.HttpServlet 中有没有办法确定在运行时调用哪个方法
- java - Scala中的Java AWT:(AWT-EventQueue-0)java.lang.NoClassDefFoundError
- python-3.x - BlockNumber 属性对象
- c - 有关命令终止事实的信息,C 中的 Shell
- asp.net-core - Boostrap 4 导航栏无法在 chrome 中正确显示