ingh.am
ingh.am

Reputation: 26822

DIV onClick in CSS

For the title of my website, I have the following code with a DIV onclick so that the user can click anywhere on the title and refresh the page:

<div class="title" onClick="document.location.href='xxxx';">

However the W3C validator tells me this:

there is no attribute "onClick"

I've read about doing this in jQuery, but I've not had much luck getting that work. Can anyone help me here?

Thanks

Upvotes: 0

Views: 2529

Answers (3)

mattsven
mattsven

Reputation: 23303

$(".title").click(function(){
    document.location.href='xxxx';
}):

Upvotes: 4

kensen john
kensen john

Reputation: 5519

Some of the options.

<div class="title" onclick="javascript:reloadPage();">

function reloadPage()
{
   window.location.reload();
}

or

<div  class="title"  onclick="window.location.href=window.location.href">

or

$(".title").click(function(){
    document.location.reload();
}):

Upvotes: 0

SLaks
SLaks

Reputation: 888223

onclick should be lowercase.

Upvotes: 1

Related Questions