English 中文(简体)
在根据 id 设定值时对 jsp 行为进行折叠
原标题:Confused about jsp behaviour while setting value based on id

在我关于准备功能的jSP里 我为一些变数设定了价值

$(document).ready(function() {
........////some code.......
var compCode=$( #companyCode ).val();
........////some code.......
$("#countrySectorinMemInfo").val(countrySec);   
........////some code.......
});

我的控制器正在返回一个值, 表示ABC和我正在访问这个值,

<input type="hidden" value="${ABC}" id="companyCode">

假设,如果我的jsp 有两个以上的字段 具有与“ 国家部门MemInfo” 相同的id

然后"$("#国别部门MemInfo")"。 val(国别安全)"将如何运作...

有人能解释我吗?

两者都会被设定, 还是只有最后的值才会被设定...??????????

最佳回答

同一 ID 的多重元素为 < a href=" "http:// validator.w3.org" rel= "nofollow" > 非法 , 在 < a href=" http://www.w3. org/TR/html4/" rel= "nofollow" > HTML 。 浏览器行为未指明。 给他们一个不同的 ID 。 如果您需要共同的选择器, 请使用 < code> name 或 < code> class 。

问题回答

我同意@BalusC

you should use class names instead of IDs. I think all of the JavaScript libraries have methods to get elements by class name. The jQuery way:

// Get all elements with class  myclass 
var nodes = $( .myclass );

YUI 2. 7. 0 选择方式 :

// Get all elements with class  myclass 
var nodes = YAHOO.util.Selector.query( .myclass ); 

YUI 2. 7 获得元素ByClass 方式 :

// Get all elements with class  myclass 
var nodes = YAHOO.util.Dom.getElementsByClassName( myclass );




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签