How to modify CSS inline after page loading?

Asked

Viewed 121 times

0

Good,

I’m doing a database query, where there is a field that has html content. Inside this content is a table, which has some CSS applied inline with a width defined in px.

I need to change the table width property to 100%; The problem is that I am showing this code by php since it comes from the database.

That is, in reality what esotu to do is just this:

echo $dados;

All the html code is within $data. I tried to explain more clearly...

I appreciate the help.

Cumps.

  • 2

    You can use jQuery if the table has some kind of class that you can pick up

  • You trigger this "event" as ? the logic is in PHP ?

  • @Khaosdoctor table has no associated class or id and I can’t assign any.

  • $('table').css('width', '100%'); ?

  • @Lucasqueirozribeiro PHP is only being used to display the comic data.

  • @Caiofelipepereira remembered this.. but this will change in all existing tables on the right page ?

  • 1

    @Luísalmeida yes. If the table you want is the first, you can do $('table:first-of-type')

  • @Caiofelipepereira Hummm... I’ll try to do it this way.. if it’s the third one I can do $('table:third-of-type') ????????

  • 2

    Your table will probably be printed inside some element that you have a certain identification ? search a table within that particular element: $( "#minhaDiv" ).find( "table" ).css( "width", "100%" );


  • @Lucasqueirozribeiro good tip... I think I got the solution... thank you.

  • 1

    @Luisa Almeida if it is the third, the selector is $('table:nth-child(3)')

  • The ideal would be for you to edit your question and put the generated HTML so that we have a better idea of how to help you

  • With your answer I already managed to modify the width of the table. : ) , I did not put html, because it is very big. But I have already reached the solution. Thank you.

  • @I will post my suggestion as an answer, if she solved your problem, accepted as an answer. :)

Show 9 more comments

1 answer

3


If your table is printed inside another element you have identified, you can use the method find() of Jquery to search only in this element.

Example:

$( "#minhaDiv" ).find( "table" ).css( "width", "100%" ); 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.