Kumar Kumar - 3 months ago 11
CSS Question

How to apply css style to custom attributes

<p target="a"><a>A</a></p>
<p target="b"><a>B</a></p>
<p target="c"><a>C</a></p>
<p target="d" ><a>D</a></p>
<p target="e"><a>E</a></p>


and i can select a custom attribute like this

$($(this).attr('target'))


But how can i add style to this,
I've tried
$($(this).attr('target')).css()
but its not working.
Thanks in advance

Answer

You can use attribute equals selector

$("[target=" + $(this).attr("target") + "]").css(/*propertyName [, propertyValue]*/)
Comments