Reputation: 1023
I'm trying to apply some styles to a div that comes right after a form but, can't get it to work with jquery. I can't set an ID of CLASS to the form because is from a joomla module.
<form action="#" method="get" name="mod_Form"></form>
<div style="text-align: center;"><a href="#" style="font-size: 10px;">Some thing here...</a></div>
This is how I'm trying to do it with jquery:
$(document).ready(function() {
$("[name=mod_Form]").next('div').css('color', 'green');
});
That code doesn't seem to work...
How can I accomplish my task?
Upvotes: 0
Views: 102
Reputation: 10356
Your code works.
In order to change the link's color Consider adding find(a)
:
$("[name=mod_Form]").next('div').find("a").css('color', 'green');
EDIT: After reading your comments: (Works for me)
Upvotes: 0
Reputation: 816462
Link elements don't inherit the text color form their parent. You have to set it explicitly on them:
$("[name=mod_Form]").next('div').find('a').css('color', 'green');
If you want to set the color for the links and the content of the div, you can include the div
with .andSelf
[docs]:
$("[name=mod_Form]").next('div').find('a').andSelf().css('color', 'green');
Upvotes: 2