我有一个JSP页面,需要在javascript函数中使用JSTL参数。我知道如何将JSTL传递给javascript,但我想使用第三个.js文件来实现,因为我的字符串参数是一个很大的字符串,而且在JSP页面中硬编码它太奇怪了
假设${ data }是我的数据,我想在我的主JSP文件中的javascript函数中使用它,如下所示:
function x(){
....
doSomeTask(myData);
}
我希望这个myData来自另一个javascript,它的主体是这样的:
var myData = ${data}; //this is a different js fil
我试图使用colorfinder.js将窗帘div的背景色设置为img中每个li中最突出的颜色。当我只给rgb一个设置值时,代码工作得很好,但是colorfinder.js返回:
Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': No function was found that matched the signature provided.
$('ul li').each(function(){
var $
我有一个表,我正在试图找到表中每个td的宽度。我尝试过各种变体:$("td")[0].width(),但它们都不起作用,每次都会出现错误:"Uncaught TypeError: $(...)[0].width is not a function"。
我先导入jQuery,然后导入其他JS文件(),我使用的是.width()而不是.width。
有什么想法吗?
不返回表单字段值
var formJSON = $.toJSON($('#form1'));
JSP是:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.
我尝试创建一个js变量,然后对该变量运行一个jquery方法。 for (var i = 0; i < $(".header").length; i++) {
let header = $(".header").get( i );
header.text("cool");
} 但是当我从变量上运行这个方法时,我得到了一个错误。 Uncaught TypeError: header.text is not a function 我试着将这两行连接在一起,但这是我能想到的全部。并且js文件肯定是连接到页面的。头类来自我的html文件,
self.$el[0].options[0]
我得到了:
<option value="asd">asd</option>
self.$el[0].options[0].attr("selected","selected")
我得到了:
is not a function.
如何在js中修改asd?是因为它是一个html元素吗?