How can I change the CSS attribute? In my case font-size
but not last but selected
$("#size").change(function() {
$("div[id^=new-text]:last").css("font-size", $(this).val() + "px");
});
How can I change the CSS attribute? In my case font-size
but not last but selected
$("#size").change(function() {
$("div[id^=new-text]:last").css("font-size", $(this).val() + "px");
});
Keep track of the selected element. Put a click
handler to set a global var to the $(this)
- where $(this)
is the clicked element.
var selectedText = null;
$('.image').on('click','.new-text', function(){
selectedText = $(this);
});
$("#size").change(function() {
selectedText.css("font-size", $(this).val() + "px");
});