Removing mouseover from a hide/show
Okay, so as the title says, I want to remove the mouseover stuff in this hide/show page. I haven't done jQuery in a long time, and I don't remember how to take care of it without creating a glitch. Here is the page:
EDIT: I removed the images so that it wouldn't be insanely cluttered, and spaced each line out so that everything would be easier to see. Sorry for posting it so sloppily. I was extremely tired last night and totally half-assed it haha. Hopefully this looks a lot better.
EDIT: I have added some indentation to the code. It looks a heck of a lot better now, I think.
NOTE: Also, is there a way for this code to be optimized? When I activated it on my website, the information that is meant to be hidden becomes "un"-hidden immediately as the button is clicked, where instead, the information should be showing as the forum expands.
- $(function() {
- $('.main-head:has(.page-title)').prepend('<a class="collapse tcatCollapse" id="collapse_c_cat1" href="#top" style="visibility: hidden; float: right; margin-top: -3px;"><img src="IMAGE HERE" alt=""></a>');
- $('.main-head:has(.page-title)').mouseover(function() {
- $(this).find('a.collapse[id]').css('visibility', 'visible')
- });
- $('.main-head:has(.page-title)').mouseout(function() {
- $(this).find('a.collapse[id]').css('visibility', 'hidden')
- });
- $('.main-head a.collapse[id]').click(function(e) {
- e.preventDefault()
- });
- $('.main-head a.collapse[id]').attr('onclick', " if($(this).closest('.main-head').next('.main-content:first').css('display')=='none') {my_setcookie($(this).closest('.main-head').find('.page-title').text()+'_ct','0',10,0); $(this).closest('.main-head').next('.main-content:first').slideDown(500);$(this).find('img').attr('src','IMAGE HERE');$(this).closest('.main-head');$(this).closest('.main-head').removeClass('collapsed')} else {my_setcookie($(this).closest('.main-head').find('.page-title').text()+'_ct','1',10,0); $(this).closest('.main-head').next('.main-content:first').slideUp(500);$(this).find('img').attr('src','IMAGE HERE'); $(this).closest('.main-head').addClass('collapsed');}");
- $(document).ready(function() {
- $('.main-head a.collapse[id]').closest('.main-head').each(function() {
- if (my_getcookie($(this).find('.page-title').text() + '_ct') == '1') {
- $(this).next('.main-content:first').css('display', 'none');
- $(this).find('a.collapse[id] img').attr('src', 'IMAGE HERE');
- $(this).closest('.main-head').addClass('collapsed')
- } else {
- $(this).next('.main-content:first').css('display', 'block');
- $(this).find('a.collapse[id] img').attr('src', 'IMAGE HERE');
- $(this).closest('.main-head').removeClass('collapsed')
- }
- })
- })
- });