admin管理员组文章数量:1415139
How to update with jquery the label of preview div when im typing inside of the parent input of edit div? Thank you.
<html>
<body>
<div id="preview">
<label id="panyName" class="workExperience">
This is my pany
</label>
</div>
<div id="edit">
<label>Company Name: </label>
<input type="text" id="panyName" />
</div>
</body>
</html>
How to update with jquery the label of preview div when im typing inside of the parent input of edit div? Thank you.
<html>
<body>
<div id="preview">
<label id="panyName" class="workExperience">
This is my pany
</label>
</div>
<div id="edit">
<label>Company Name: </label>
<input type="text" id="panyName" />
</div>
</body>
</html>
Share
Improve this question
asked Aug 11, 2010 at 19:26
BoDiE2003BoDiE2003
1,3596 gold badges29 silver badges41 bronze badges
4
-
Could you rephrase a bit? Among other things, I find "parent input" evry confusing; the
<input />
element isn't parent to anything. – Richard JP Le Guen Commented Aug 11, 2010 at 19:33 -
Note that
keyup
doesn't react to pasting with the mouse andchange
doesn't update "as-you-type". – Stephen P Commented Aug 11, 2010 at 20:05 - Exact duplicate of your own question – Stephen P Commented Aug 11, 2010 at 20:16
- No, the question was stackoverflow./questions/3462515/… Bue seems like noone understood – BoDiE2003 Commented Aug 11, 2010 at 20:48
2 Answers
Reset to default 4You'd have to have something along these lines in your code:
<script>
$("#panyName").keyup(function () {
var value = $(this).val();
$(".workExperience").text(value);
}).keyup();
</script>
However, I would NOT give them the same id value, as it might lead to some errors.
Good luck!
you can not have the same ID in the tag "label" and the tag "input".
<div id="preview">
<label id="panyName" class="workExperience">
This is my pany
</label>
</div>
<div id="edit">
<label>Company Name: </label>
<input type="text" id="panyNameInput" />
</div>
$(document).ready(function(e){
$('#panyNameInput').bind('change', function(ev) {
$(this).closest('#edit').prev().find('#panyName').html($(this).val());
});
});
test
本文标签: Javascript Update label content while typing inside of a parent input with JqueryStack Overflow
版权声明:本文标题:Javascript: Update label content while typing inside of a parent input with Jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745216107a2648175.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论