var password = $('#tpass')val();
上面这2句是获取控件值的,不是获取ID 获取ID $(“#tname”)attr("id")、$(“#tpass”)attr("id")大致是HtmlControl被服务器发送到页面ID不变,比如<div id="a" runat="sever"></div>
WebControl 被服务器发送到页面,如果在其他循环控件里,或者在用户控件中,ID会变,
用documentgetElementById("<%=Button1ClientID%>")
这个你多看看页面源代码,就知道什么时候会变。什么时候不会变
类似取Text需要这样写:documentgetElementById("<%=Button1ClientID%>")value
而不是直观意义上documentgetElementById("<%=Button1ClientID%>")text
这个是javascript语言,就这个语法,这个属性,就用value取值,在js中就是这样,没什么说的
如果是在net后台,才用Button1Text是文本框 <input type="button">这种么 如果是的话 直接$("input[type=button]")val("你想写啥就写啥") 就能完成赋值了利用Javascript取和设FCKeditor值也是非常容易的,如下:
// 获取编辑器中HTML内容
function getEditorHTMLContents(EditorName) {
var oEditor = FCKeditorAPIGetInstance(EditorName);
return(oEditorGetXHTML(true));
}
// 获取编辑器中文字内容
function getEditorTextContents(EditorName) {
var oEditor = FCKeditorAPIGetInstance(EditorName);
return(oEditorEditorDocumentbodyinnerText);
}
// 设置编辑器中内容
function SetEditorContents(EditorName, ContentStr) {
var oEditor = FCKeditorAPIGetInstance(EditorName) ;
oEditorSetHTML(ContentStr) ;
}上面的全是错的因为服务器控件render到客户端的时候如果有panel或者masterpage那么id是会变的,应该用documentgetelementbyid('<%=textbox1clientid%>');
这样无论怎样都能获取到textbox了
--------
原理asp:textbox生成后事<input
type="text"
id="masterpageid_panelid_id">
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)