darksniperx Posted October 6, 2010 Share Posted October 6, 2010 Hi, I have the following line: $.fn.colorbox({inline:'true', href:'#content-area',width:'700px', height:getHeight() }); From the following code: var boxHeight = document.getElementById('content-area').clientHeight; function getHeight(){ boxHeight += 90; return boxHeight = boxHeight + "px"; } if(boxHeight > 200){ $(document).ready(function(){ $.fn.colorbox({inline:'true', href:'#content-area',width:'700px', height: getHeight() }); });} jquery fn.colorbox just would not run if I put getHeight() in it. Any ways to go around it or fix it? Quote Link to comment https://forums.phpfreaks.com/topic/215255-running-a-javascript-function-inside-jquery/ Share on other sites More sharing options...
Adam Posted October 7, 2010 Share Posted October 7, 2010 Well it looks to me like you're trying to get the object before it's even been created. Try this: var boxHeight;function getHeight(){ boxHeight += 90; return boxHeight = boxHeight + "px"; }$(document).ready(function(){ boxheight = $('content-area').height(); if (boxheight > 200){ $.fn.colorbox({inline:'true', href:'#content-area',width:'700px', height: getHeight() }); }}); Quote Link to comment https://forums.phpfreaks.com/topic/215255-running-a-javascript-function-inside-jquery/#findComment-1119701 Share on other sites More sharing options...
darksniperx Posted October 7, 2010 Author Share Posted October 7, 2010 I cant say if what was the case or not. but it seemed the colorbox was not compatible with jquery 1.4.1 and I have applied 1.3.2 for which it automatically grabs the height, and I dont need to specify it. But thx for the suggestion. I will test the code separately. Quote Link to comment https://forums.phpfreaks.com/topic/215255-running-a-javascript-function-inside-jquery/#findComment-1119984 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.