JQuery Variable Configuration Overview
I recently became familiar with setting up a jQuery variable, as shown below, with the help I was looking for on another question I had on StackOverflow. You can create an input field simply by calling a variable, and it also appears that the binding variable also defines the styles!
var clicked = $('.clicked');
var ul = clicked.children('ul');
var input = $('<input />', {
type: 'text',
class: 'rename',
value: 'New Folder',
focusout: function() {
$(this).siblings('a').html($(this).val()).show();
$(this).remove();
$(anchor).parent().removeClass('clicked');
}
});
var anchor = $('<a>', {
href: '#',
css: {
display: 'none'
}
});
ul.prepend($('<li>').append([input.select(), anchor]));
I believe that I understand how to modify and recreate the above snippet, the only aspect that I really don’t understand is the style setting. According to my research, I have not found anything like this method yet, and I hope that I can find more understanding by posting a question.
, : , .selectBoxIt() .
UPDATE
, , , , ;
var select = $('<select />');
var options = [
{val : 1, text: '3 DAYS'},
{val : 2, text: '10 DAYS'},
{val : 3, text: '30 DAYS'},
{val : 4, text: '60 DAYS'}
];
$('.hello').prepend(select);
$(options).each(function() {
select.append($("<option>").attr('value',this.val).text(this.text));
});
$(".hello select").selectBoxIt();
user2199267