javascript - Jquery: div Hyperlink -


knewb here, have made textless, blocked, div clickable jquery , css. upon click load new url browser taking visitor away website stackoverflow.com. can jquery? if how?

 #star{     width:130px;     height:40px;     outline:1px solid orange;     display:block;     cursor:pointer;     }  <div id="star">star</div>  <script>         $("#star").click(function(evt){         $(this).html("http://www.stackoverflow.com");     }); </script> 

second question have have div transparent or empty menu background shows, (no slicing.). can or , should transparent gif?

btw: how modify code local url? thank you!

the first part relatively easy:

$("#star").click(function(evt){     window.location = 'http://stackoverflow.com'; }); 

as transparency, add following css:

#star {     /* other stuff */     background-color: transparent; } 

or, if don't need full cross-browser compatibility:

#star {     /* other stuff */     background-color: rgba(255,255,255,0.1); } 

the above make element's background-color white, alpha transparency of 0.1 (0 being transparent, 1 being opaque).

note, wasn't quite sure meant 'local url,' if mean possible use relative path, example change:

'http://server.com/news/index.html' 

to:

'http://server.com/some/other/directory/index.html' 

without using absolute path in javascript, following should work:

$("#star").click(function(evt){     window.location.pathname = '/somewhere_else/on/the/same/server'; }); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -