Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
196
rated 0 times [  198] [ 2]  / answers: 1 / hits: 58234  / 13 Years ago, fri, may 27, 2011, 12:00:00

Just a quick example:



<p>
<span class=example></span>
<input type=text name=e_name id=e_id />
</p>
<script type=text/javascript>
$('input').click(function(){
$(this).parent().children('span').text('Suprise!');
}
</script>


What can I use instead parent().children()?



I think it's a bit inelegant piece of code.
Is any function i.e : $(this).fun('span').text('just better'); ??


More From » jquery

 Answers
11
$(this).siblings('span').text('Suprise!');

[#92015] Thursday, May 26, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alexandreah

Total Points: 720
Total Questions: 85
Total Answers: 90

Location: Central African Republic
Member since Fri, Jun 5, 2020
4 Years ago
;