apply css using jquery code example
Example 1: jquery css
$('#element').css('display', 'block');
$('#element').css({'display': 'block', 'background-color' : '#2ECC40'});
Example 2: jquery element css
//Set one style attribute
$('#element').css('display', 'block');
//Set multiple style attributes
$('#element').css({'display': 'block', 'background-color' : '#2ECC40'}); /* Multiple style *
Example 3: set css using jquery
$('.name').css('color':'blue');
Example 4: add css file through jquery
$('head').append('<link rel="stylesheet" href="style2.css" type="text/css" />');
Example 5: edit css jquery
$('.ama').css('color','red');
Example 6: jquery css
--------------------------------------------------------------
Method:
const element = $("#element")
function update_change_css(field, val)
{
element.css(field, val)
}
Usage:
const element = $("#element")
function update_change_css(field, val)
{
element.css(field, val)
}
update_change_css("display", "block")
update_change_css("background-color", "red")
update_change_css("width", "100%")
update_change_css("color", "aqua")
--------------------------------------------------------------
OR
--------------------------------------------------------------
Method:
$('#element').css("property", "property value")
Usage:
$('#element').css("color", "red")
$('#element').css("background-color", "blue")
$('#element').css("font-size", "30px")
--------------------------------------------------------------
OR
--------------------------------------------------------------
Method:
const element = $("#element")
function update_change_css(val)
{
element.css("color", val)
}
Usage:
const element = $("#element")
function update_change_css(val)
{
element.css("color", val)
}
update_change_css("black")
update_change_css("red")
update_change_css("blue")
update_change_css("aqua")
--------------------------------------------------------------