I have a dynamic table here, i'am trying to add css poperty using jquery for small devices. but iam not getting the output, here is my code
$("#slidetable td:nth-of-type(8):before").css("content:","Credit WP");
I have a dynamic table here, i'am trying to add css poperty using jquery for small devices. but iam not getting the output, here is my code
$("#slidetable td:nth-of-type(8):before").css("content:","Credit WP");
You can't target pseudo-elements (:before, in this case) with JavaScript. Also you can just use CSS Media Queries to target specific device sizes:
A media query consists of a media type and at least one expression that limits the style sheets' scope by using media features, such as width, height, and color.
@media screen and (max-device-width: 460px) {
#slidetable td:nth-of-type(8):before {
content: "Credit WP";
}
}
@ james Donnelly but my table is dynamic – kannan D.S
That doesn't matter. Here is a JSFiddle demo showing how a dynamically-created div
element is still affected by CSS: http://jsfiddle.net/gvdt22h2.
if content: "Credit WP"; is dynamic then how it is possible – kannan D.S
In this case you'll need to use a different element instead of CSS's generated content. You could use a span
element, for instance:
$("#slidetable td:nth-of-type(8)").append('<span>Credit WP</span>');