I try to keep it simple,
I have a hidden-html structure generated in an each loop, holding a video-title as text and a video id as data-id=""
attribute
<ul id="videoholder" style="display:none;">
<li class="videodata" data-id="sD__BIzTVlE">great title</li>
<li class="videodata" data-id="GN8B2l3ouxc">even greater</li>
</ul>
in the same loop i´m generating textfields for changing the title of the Video looking like:
<input type="text" name="titel[0]" class="float videotitel" data-id="sD__BIzTVlE" value="great title" id="titel[0]" /></div>
now i need to bind changing a textfield with replacing the text in the <li>
matching to the data-id
I tried doing so :
$('.videotitel').bind('keyup', function(){
var data = $(this).attr('data-id');
var title = $(this).val();
$('.videodata[data-id*='data']').text(title) ;
})
but i´m not able to insert the variable data
SyntaxError: missing ) after argument list
anybody got a hint how to get this done ? thanks a lot
You need to concatenated data within selector.
Change
$('.videodata[data-id*='data']').text(title) ;
To
$('.videodata[data-id*='+ data + ']').text(title) ;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.