user1755043
user1755043

Reputation: 281

Using ready() function to set elements to display but $(this) won't work?

$('.share-button').ready(function(){
  $(this).css("display","inline");
});

I set all of my social media share buttons in a wrapper with display:none then I want to set them to display after they load. I am trying to use this function but it won't work. What do you think could be wrong?

Edit: My problem is that each button has to load an outside script so they are usually continuing to load after the page loads and their loading kind of glitches and things are resizing making it look weird. I need to do the function for each individual element.

Upvotes: 0

Views: 59

Answers (5)

coonooo
coonooo

Reputation: 205

just insert javascript tag after those .share-button and insert you code:

$('.share-button').css("display","inline");

Upvotes: 0

Andrew Liu
Andrew Liu

Reputation: 2548

and this

$(function() {//this format is same as document.ready
    $('.share-button').css("display","inline");
});

Upvotes: 0

chank
chank

Reputation: 3636

Why don't you do,

$(document).ready(function() {
  $('.share-button').css("display","inline");
});

documentation says $().ready(handler) (this is not recommended)

Upvotes: 0

palaѕн
palaѕн

Reputation: 73896

You can do this after DOM fully loads:

$(document).ready(function(){
  $('.share-button').show();
});

Upvotes: 3

tymeJV
tymeJV

Reputation: 104775

Set them after the page load inside a DOM ready function:

$(document).ready(function() {
    $('.share-button').css("display","inline");
});

API: http://api.jquery.com/ready/

Upvotes: 3

Related Questions