Link to home
Start Free TrialLog in
Avatar of smfmetro10
smfmetro10Flag for United States of America

asked on

Jquery not working in Safari

Hi,

I have a jquery function that works in FF, IE and Chrome but wont work in safari

<script type="text/javascript">
$(document).ready(function(){
    $('#<!--$ tdcDateID-->').click(function(){
        $(this).next().toggle();
                 
        $(this).html($(this).text() == 'Less' ?'More' : 'Less');
        $('#<!--$ tdcLocationID -->').toggle();
        
    });
})
</script>


                         <a id="<!--$ tdcDateID-->">More</a>
                               <div style="width:80px;" id="<!--$tdcDateID-->" class="moredates data-collapsed="true">  

Some info....
</div>

Thanks for the help!

Open in new window

Avatar of leakim971
leakim971
Flag of Guadeloupe image

set a test page here as SIMPLE as you can : http://jsfiddle.net/
Your identifier in this statement...

<a id="<!--$ tdcDateID-->">More</a>

is formatted as an HTML comment.  I'm surprised your code works in any browser.  In particular because I think javascript expects a letter as the first character.  What happens if you use just...

<a id="tdcDateID">More</a>
In the Firefox Error Console, I get

[19:07:56.625] Error: Syntax error, unrecognized expression: #<!--$ tdcDateID--> @ http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js:4

and it doesn't work.  If I put 'tdcDateID' in for the 'id', it does work, both in Firefox on my PC and Safari on my MacBook Pro.
Avatar of smfmetro10

ASKER

<!--$ tdcDateID--> is an Idoc script variable.
I set up a test fiddle... Don't know if it will help as there are a lot of Idoc script variables in the function.  Viewing the source on safari confirms that the variables are being picked up though.

http://jsfiddle.net/smfmetro/DR5mq/
It doesn't help because the "Idoc script variables" are not valid by themselves in javascript.  If you could give us an example from the 'View Source" that is not working then we might be able to figure it out.
OK- thanks for the help!

This is straight out of the view source of safari:

<script type="text/javascript">
     $(document).ready(function(){
    $('#CON_ID_004633_1').click(function(){
   $(this).html($(this).text() == '[-]' ?'[+]' : '[-]');
        $('#CON_ID_004633_B').toggle();
         $('#CON_ID_004633_A').toggle(); 
    });
})
</script>
<a id="CON_ID_004633_1">[+]</a><span style="color:#959595;">&nbsp;&nbsp;&nbsp;&nbsp;Sep 5</span>
                               <div style="width:80px;" id="CON_ID_004633_A" class="moredates" data-collapsed="true">   
						<span style="color:#959595;">Oct 5</span>
						<br />
						<span style="color:#959595;">Dec 5</span>
						<br />
				</div>

   <div style="width:135px;" id="CON_ID_004633_B" class="moredates" data-collapsed="true"> 
					
						<span style="color:#959595;">CA - San Francisco</span><br />
						<span style="color:#959595;">OR - Portland</span><br />
			</div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yeah I hear ya. Works for me too. Safari must be getting tangled up somewhere else in the code... OK -  thanks!
You're welcome, glad to help.