0

I have some problems validate my template with http://validator.w3.org hope someone can let me know how i can fix this via jquery.

<a href="/video/213123/"><img src="/media/videos/tmb/213123/1.jpg" title="Funny Videos" alt="Funny Videos" /><div class="Title_URL">Girls Funny Videos</div></a>

When i validate my html page with http://validator.w3.org its say div Title_URL its not allow there ... but i need it because of my design ... its any way to make it via jquery so i don't have that error anymore ?

Mihai Viteazu
  • 1,631
  • 3
  • 13
  • 15

2 Answers2

1
<a href="/video/213123/" id="href1"><img src="/media/videos/tmb/213123/1.jpg" title="Funny Videos" alt="Funny Videos" id="img1"/></a>

$('#img1').html = "<div class='Title_URL'>Girls Funny Videos</div>";

Here is the fiddle for your answer

http://jsfiddle.net/mastermindw/ASJW2/

and validator shows it as Passed

http://fiddle.jshell.net/mastermindw/ASJW2/show/

http://validator.w3.org/check?uri=http%3A%2F%2Ffiddle.jshell.net%2Fmastermindw%2FASJW2%2Fshow%2F&charset=%28detect+automatically%29&doctype=Inline&group=0

wakqasahmed
  • 2,059
  • 1
  • 18
  • 23
0

I suggest you render it as a <span> instead of a <div> when you're outputting the page. That way it will get validated properly. Then you can use the following code to replace it using jQuery:

$( 'a span' ).each(function() {
    $( this ).replaceWith( $( '<div>' + this.innerHTML + '</div>' ) );
});
Grampa
  • 1,623
  • 10
  • 25