So, when i click a button my jQuery dosent change the value of the div, this onaly happens in safari in all other browsers it works!

Javascript:

$(document).keypress(function(){
	if (event.keyCode==13) key('=');
	if (event.keyCode==42) key('*','x');
	if (event.keyCode==43) key('+','+');
	if (event.keyCode==45) key('-','-');
	if (event.keyCode==46) key('.');
	if (event.keyCode==47) key('/','÷');
	if (event.keyCode==48) key(0);
	if (event.keyCode==49) key(1);
	if (event.keyCode==50) key(2);
	if (event.keyCode==51) key(3);
	if (event.keyCode==52) key(4);
	if (event.keyCode==53) key(5);
	if (event.keyCode==54) key(6);
	if (event.keyCode==55) key(7);
	if (event.keyCode==56) key(8);
	if (event.keyCode==57) key(9);
});
function key(x,y){
	if (y){
		$('#temp').append(x);
		$('#screen').append(y);
	} else {
		if (x=='ac'){
			$('#screen').html(0);
			$('#temp').html('');
			$('#op').html('');
		} else {
			if (x=='='){
				$('#screen').html(eval($('#temp').html()));
			} else {
				$('#temp').append(x);
				if ($('#screen').html()==0){
					$('#screen').html(' ');
				};
				$('#screen').append(x)
			}
		}
	}
}

HTML:

<div id="temp"></div>
    <div class="screen">
      <div id="screen">0</div>
    </div>
    <div class="top">
      <button onclick="key('ac')" id="ac">AC</button>
      <br />
    </div>
    <div class="round">
      <button onclick="key(7)">7</button>
      <button onclick="key(8)">8</button>
      <button onclick="key(9)">9</button>
      <button onclick="key('/','&divide;');">&divide;</button>
      <br />
      <button onclick="key(4)">4</button>
      <button onclick="key(5)">5</button>
      <button onclick="key(6)">6</button>
      <button onclick="key('*','x');">x</button>
      <br />
      <button onclick="key(1)">1</button>
      <button onclick="key(2)">2</button>
      <button onclick="key(3)">3</button>
      <button onclick="key('-','-');">-</button>
      <br />
      <button onclick="key('.')">•</button>
      <button onclick="key(0)">0</button>
      <button onclick="key('=')">=</button>
      <button onclick="key('+','+');">+</button>
    </div>

What happens if you change

<button onclick="key(7)">7</button>

to

<input type="button" onclick="key(7)" value="7" />

, etcetera?

my css is just styling the button tag, so the rounded effect wont go on, dont really see how that would effect it though.

Yes, but you could use input[type=button] in your CSS, too. Another idea is to change onclick to onfocus.

i shall try

Solved:

JavaScript was off as safari is my noscript testing browser, silly of me.

Haha, okay :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.