Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

jQuery .css() method

0 votes
17 views
added Jul 12, 2017 in jQuery by birdygeek Sergeant (2,060 points)
// Add CSS properties into .AddCssIntoThisClass
$(".AddCssIntoThisClass").css({"height": "64px", "overflow": "hidden"});

6 Responses

0 votes
responded May 4 by LC Marshal Lieutenant (13,570 points)
//important - to overwrite important CSS
$( '.myclass' ).each(function () {
  this.style.setProperty( 'height', '0px', 'important' );
});
0 votes
responded May 4 by LC Marshal Lieutenant (13,570 points)
//Add CSS attr to elements
$(document).ready(function() {
  $('#div1, #div2').attr('class','NewCSSClass');
});
0 votes
responded May 4 by LC Marshal Lieutenant (13,570 points)
//Close div with css method, e.g toggle menu
$('.business-details__toggle').click(function() {
  $('.sidr.left').css('left', '0rem');
});
    
  $('.sidr__toggle').click(function() {
  $('.sidr.left').css('left', '-44rem');
}); 
0 votes
responded May 4 by LC Marshal Lieutenant (13,570 points)
//Add style attributes to specific element
$("#page-content").find(".details").css( { marginLeft : "30px", marginRight : "30px" } );

//or
$("#page-content").find(".details").css( 'min-height', '128px');
0 votes
responded May 4 by LC Marshal Lieutenant (13,570 points)
//To change only style attributes
$('.handle').attr('style','left: 300px');
0 votes
responded May 4 by LC Marshal Lieutenant (13,570 points)
//To add style properties
$('.handle').css('left', '300px');
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...