目前,我试图用 j子操纵两种不同类型的控制(标签和投入)的内容。 到目前为止,我正在通过使用两条指挥部这样做。
if(true)
{
myControl.text( @types.Text );
myControl.val( @types.Text );
}
是否有能够做到的指挥?
附带说明:我已尝试过html()和附录(),但我认为这些改动是案文()和阀()上的改动。
目前,我试图用 j子操纵两种不同类型的控制(标签和投入)的内容。 到目前为止,我正在通过使用两条指挥部这样做。
if(true)
{
myControl.text( @types.Text );
myControl.val( @types.Text );
}
是否有能够做到的指挥?
附带说明:我已尝试过html()和附录(),但我认为这些改动是案文()和阀()上的改动。
我在贾瓦Script文的公用事业中使用类似的东西。
$.fn.setValue = function(val) {
return this.each(function() {
switch (this.tagName.toLowerCase()) {
case "input":
switch ($(this).attr("type").toLowerCase()) {
case "hidden":
case "password":
case "text":
$(this).val(val); break;
case "radio":
case "checkbox":
this.checked = val; break;
} break;
case "span":
case "button":
case "label":
$(this).html(val); break;
case "select":
case "textarea":
$(this).val(val); break;
}
});
};
然后,你可以利用你的新职能,几乎没有任何内容,而不必担心什么。
var myControl = $( #someSelector );
myControl.setValue( @Types.text );
你可以写自己的话:
$.fn.tval = function (value) {
if (this.is( :input:not(:checkbox):not(:radio) )) {
this.val(value);
}
else {
this.text(value);
}
return this;
}
没有将<编码>文本()与val(<>/code>合并的指令。 是否有这方面的书面习惯功能问题? 方式是:虽然
text()
和html(
)几乎相同,但val(>
和append(<>
) 是 VERY ——核对分类文件。
如果你也想支持阀和案文的左边:
$.fn.tval = function(value) {
if (value) {
if (this.is( :input:not(:checkbox):not(:radio) )) {
this.val(value);
} else {
this.text(value);
}
return this;
}else{
if (this.is( :input:not(:checkbox):not(:radio) )) {
return this.val();
} else {
return this.text();
}
}
}
The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...
I have a div <div id="masterdiv"> which has several child <div>s. Example: <div id="masterdiv"> <div id="childdiv1" /> <div id="childdiv2" /> <div id="...
I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.
I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...
Ok, I m stumped. Basically, this script works fine in FF, but not in IE (6,7 or 8) - in which it returns an "Object doesn t support this property or method" error. Any ideas?: function ...
What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...