Как сделать стиль применяется - PullRequest
0 голосов
/ 22 ноября 2010

Как сделать, чтобы стиль применялся только к выбранному объекту, а не ко всем сразу?

 $('#add_text').mousedown
        (
            function() 
            {                              
                $('#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});     
            }       
        ); 

1 Ответ

1 голос
/ 22 ноября 2010

Вы можете сделать следующее, чтобы изменить только элемент, вызвавший событие в JQuery:

$(document).ready(function() {

    $('#add_text').mousedown(function() {

        // the this keyword references the element where the mousedown
        // event has occurred
        $(this).css(...);

    });

});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...