问题描述
< tr> < TD> Facebook:< / td> < TD> < input style =width:300pxtype =textname =facebookvalue =http://www.facebook.com/$facebook> < / td>< / tr>
$ b $ p
更新:
$ facebook
部分需要可编辑!
有两种方法可以做到这一点。一种是向它添加属性 disabled =disabled
,或者向它添加 readonly
。
两者的工作方式不同。你需要的可能是 disabled =disabled
属性。
$ b
编辑
已更新。您应该包含以下jQuery代码:
$ $ $ $ $ $ $ $ $ $ $ $ $' inpt).val('http://www.facebook.com/$facebook');
$(#inpt)。on('change',function(){
var tval = $(this).val();
$(this).val('http://www.facebook.com/'+ tval.substring(24));
});
});
你也可以使用键盘事件,我自己是jQuery的初学者,因此这个基本的代码片段。 :)另外,将输入
标记更新为:
< input id =inptstyle =width:300pxtype =textname =facebookvalue =您想要的任何价值>
I have a textbox to save the user facebook's url.
<tr>
<td>
Facebook:
</td>
<td>
<input style="width:300px" type="text" name="facebook" value="http://www.facebook.com/$facebook">
</td>
</tr>
How can i make the value "http://www.facebook.com/" fixed and uneditable?
UPDATE:
the $facebook
part needs to be editable!!
There are two methods to do this. One is to add the attribute disabled="disabled"
to it, or add readonly
to it.
Both work differently. What you need might be disabled="disabled"
attribute.
EDIT
fiddle updated. You should include following jQuery code:
$(document).ready(function() {
$("#inpt").val('http://www.facebook.com/$facebook');
$("#inpt").on('change', function() {
var tval = $(this).val();
$(this).val('http://www.facebook.com/' + tval.substring(24));
});
});
You may use keyboard events too, I am myself a beginner in jQuery, hence this basic piece of code. :) Also, update the input
tag to this:
<input id="inpt" style="width:300px" type="text" name="facebook" value="Any VALUE YOU WANT">
这篇关于如何修复文本框中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!