How to make the style is applied only to the chosen object, and not all at once?
$('#add_text').mousedown
(
func开发者_开发问答tion()
{
$('#add_text').css('background-color', 'blue'),
$('#template').prepend('<div id="text_frame"><input class="input_text"/></div>'),
$('div#text_frame').attr("class", function (arr) {return "nomber" + arr;}),
$('div#text_frame').mousedown(function(){$('div#text_frame').addClass('select_text_frame');}),
$('#text_frame').draggable('enable'),
$('#text_frame').draggable({containment: '#template', distance: 1});
}
);
You can do the following to modify only the element that invoked the event in JQuery:
$(document).ready(function() {
$('#add_text').mousedown(function() {
// the this keyword references the element where the mousedown
// event has occurred
$(this).css(...);
});
});
精彩评论