jQuery Plugins » function https://jqueryplugins.info jQuery plugins, tutorials and resources Fri, 21 Oct 2011 17:13:56 +0000 en hourly 1 http://wordpress.org/?v=3.2.1 Click function on list shouldn’t affect nested ul https://jqueryplugins.info/2011/10/click-function-on-list-shouldnt-affect-nested-ul/ https://jqueryplugins.info/2011/10/click-function-on-list-shouldnt-affect-nested-ul/#comments Thu, 20 Oct 2011 16:13:59 +0000 Admin https://jqueryplugins.info/2011/10/click-function-on-list-shouldnt-affect-nested-ul/ Post link: Click function on list shouldn’t affect nested ul

My problem is that I only want Header 1 and Header 2 to call the click function. If i click on List item 1.1 etc I want nothing to happen....

]]>
Post link: Click function on list shouldn’t affect nested ul

My problem is that I only want Header 1 and Header 2 to call the click function. If i click on List item 1.1 etc I want nothing to happen. As it is now, clicking on any list item will call the event.

Javascript

$  (document).ready(function() {
    $  ("ul#nav li ul").hide();
    $  ("ul#nav li").click(function() {
        $  ("ul#nav li").removeClass("current");
        $  (this).addClass("current");
        $  ("ul#nav li ul").slideUp('fast');
        $  (this).find("ul").slideDown('fast');
    });
});

HTML

    <ul id="nav">
        <li><a href="#">Header 1</a>
        <ul>
           <li>List item 1.1</li>
           <li>List item 1.2</li>
           <li>List item 1.3</li>
        </ul>
        </li>
       <li><a href="#">Header 2</a>
       <ul>
           <li>List item 2.1</li>
           <li>List item 2.2</li>
           <li>List item 2.3</li>
       </ul>
       </li>
    </ul>

I have looked through a couple of similar questions and answers but they did not quite help me to solve the problem.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/click-function-on-list-shouldnt-affect-nested-ul/feed/ 0
Can $(this ) object be used to point to a function https://jqueryplugins.info/2011/10/can-this-object-be-used-to-point-to-a-function/ https://jqueryplugins.info/2011/10/can-this-object-be-used-to-point-to-a-function/#comments Wed, 19 Oct 2011 05:13:56 +0000 Admin https://jqueryplugins.info/2011/10/can-this-object-be-used-to-point-to-a-function/ Post link: Can $(this ) object be used to point to a function

I have a code something below: function showHideOptions() { $ ("#template1, #template2, #template3, #template4").css("display","none"); $ (this).css("display","block"); } And I have four select dropdowns, At a particular time I want to...

]]>
Post link: Can $(this ) object be used to point to a function

I have a code something below:

    function showHideOptions() {
        $  ("#template1, #template2, #template3, #template4").css("display","none");
        $  (this).css("display","block");
}

And I have four select dropdowns, At a particular time I want to select only one on the option of template selector.

    <select id="masterdropdown">
        <option>T1</option>
        <option>T2</option>
        <option>T3</option>
        <option>T4</option>
    </select> 

<select id="template1" onchange="return showHideOptions();">
        <option>Template1</option>
        <option>Template2</option>
        <option>Template3</option>
        <option>Template4</option>
    </select> 

<select id="template2"  onchange="return showHideOptions();">
        <option>Template1</option>
        <option>Template2</option>
        <option>Template3</option>
        <option>Template4</option>
    </select> 

<select id="template3" onchange="return showHideOptions();">
        <option>Template1</option>
        <option>Template2</option>
        <option>Template3</option>
        <option>Template4</option>
    </select> 

<select id="template4" onchange="return showHideOptions();">
        <option>Template1</option>
        <option>Template2</option>
        <option>Template3</option>
        <option>Template4</option>
    </select>

CSS:

#template1, #template2, #template3, #template4{display:none;}

Basically I have a top dropdown(masterdropdown), which is always Visible this is also a template selector, On select of its options I want to show a particular template drodown that corresponds to that selected option in masterdropdown. How can this be acheived in jquery. does $ (this) not work in this case, being called from a function.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/can-this-object-be-used-to-point-to-a-function/feed/ 0
jQuery plugin: How to access elements where plugin was applied from secondary function? https://jqueryplugins.info/2011/10/jquery-plugin-how-to-access-elements-where-plugin-was-applied-from-secondary-function/ https://jqueryplugins.info/2011/10/jquery-plugin-how-to-access-elements-where-plugin-was-applied-from-secondary-function/#comments Wed, 19 Oct 2011 02:13:21 +0000 Admin https://jqueryplugins.info/2011/10/jquery-plugin-how-to-access-elements-where-plugin-was-applied-from-secondary-function/ Post link: jQuery plugin: How to access elements where plugin was applied from secondary function?

I am new to jQuery and I am building a custom plugin, it looks something like this (pseudo-code): jQuery.fn.myPlugin = function( options ) { var defaults = { interval :...

]]>
Post link: jQuery plugin: How to access elements where plugin was applied from secondary function?

I am new to jQuery and I am building a custom plugin, it looks something like this (pseudo-code):

jQuery.fn.myPlugin = function( options )
{

    var defaults = {
        interval : 5 * 1000
    };

    var interval_handler = setInterval( function( ) { update( ); }, interval );

    var opts = $  .extend( defaults, options );

    return this.each( function( ){
        $  ( this ).bind( event, stuff );
    });

    function update( )
    {
        if ( condition == true )
        {
            clearInterval( interval );

            // unbind() foreach element the plugin has used
        }
    }
}

My question is:

How can access all the elements the plugin has used on return this.each(...) from the update( ) function?

Also, is the way im using functions inside the plugin correct? I didn’t know how to do it so I just tried that and it worked.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/jquery-plugin-how-to-access-elements-where-plugin-was-applied-from-secondary-function/feed/ 0
In jQuery, cannot use a hover function into an each function? https://jqueryplugins.info/2011/10/in-jquery-cannot-use-a-hover-function-into-an-each-function/ https://jqueryplugins.info/2011/10/in-jquery-cannot-use-a-hover-function-into-an-each-function/#comments Mon, 17 Oct 2011 08:13:59 +0000 Admin https://jqueryplugins.info/2011/10/in-jquery-cannot-use-a-hover-function-into-an-each-function/ Post link: In jQuery, cannot use a hover function into an each function?

This is probably an easy question, but since I’m new to jQuery, I need someone to look at this code for me. So basically I want to change the css...

]]>
Post link: In jQuery, cannot use a hover function into an each function?

This is probably an easy question, but since I’m new to jQuery, I need someone to look at this code for me. So basically I want to change the css of the hover state of multiple anchor tags, I tried the following code but it didn’t work. What’s wrong with that?

(".p-container a").each(function () {
    $  (this).css({'text-shadow':'0 0 0.2px '+ colorArray[i]});
    $  (this).hover(function() {
           $  (this).css({'text-shadow':'0 0 2px '+ colorArray[i]});
    },function() {
           $  (this).css({'text-shadow':'0 0 0.2px '+ colorArray[i]});
    });
    i++;
});

The code works without having the hover function, but I want to change the css of the hover state at the same time. Is anybody know how to do that?

Thanks
KJ

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/in-jquery-cannot-use-a-hover-function-into-an-each-function/feed/ 0
my jquery vertical center function doesn’t work with -moz-inline-stack block element https://jqueryplugins.info/2011/10/my-jquery-vertical-center-function-doesnt-work-with-moz-inline-stack-block-element/ https://jqueryplugins.info/2011/10/my-jquery-vertical-center-function-doesnt-work-with-moz-inline-stack-block-element/#comments Mon, 17 Oct 2011 07:13:55 +0000 Admin https://jqueryplugins.info/2011/10/my-jquery-vertical-center-function-doesnt-work-with-moz-inline-stack-block-element/ Post link: my jquery vertical center function doesn’t work with -moz-inline-stack block element

hi guys I was testing some divs with -moz-inline-stack I came across two problems: I found that if a parent div’s display is -moz-inline-stack its child’s height will automatically be...

]]>
Post link: my jquery vertical center function doesn’t work with -moz-inline-stack block element

hi guys I was testing some divs with -moz-inline-stack
I came across two problems:

  1. I found that if a parent div’s display is -moz-inline-stack
    its child’s height will automatically be set to 100% in firefox
    even I have specified its height in css

    • what’s -moz-inline-stack’s default setting ?

    • and do we still use -moz-inline-stack anymore
      from my research it seems like a fix for old firefox

  2. I wrote a jquery function that will vertically centre
    the child div which nested a img but firefox seems to ignore this function

    • I am not too sure why

here’s the code

html:

<body>
    <div id="box">

        <div id="img_box">
            <img src="images/logo.jpg">
        </div>

    </div>
</body>

css:

#box{

    display:inline-block;
    display:-moz-inline-stack;
    overflow:hidden;
    background:#999;
    height:50px;

}

#img_box{
    background:#CCC;
    height:20px;
}

script:

<script src="jquery-1.6.1.min.js"></script>
<script>

function centre_div(target_div,parent_div){

    var target_height= parseInt($  (target_div).css("height"));
    var parent_height= parseInt($  (parent_div).css("height"));
    var margin= (parent_height-target_height)/2+"px";
    String(margin);
    $  (target_div).css('marginTop',margin);

}

$  (document).ready(function(){

    centre_div("#img_box","#box");

});

</script>

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/my-jquery-vertical-center-function-doesnt-work-with-moz-inline-stack-block-element/feed/ 0
Run function based on hash tag using jQuery or Javascript https://jqueryplugins.info/2011/10/run-function-based-on-hash-tag-using-jquery-or-javascript/ https://jqueryplugins.info/2011/10/run-function-based-on-hash-tag-using-jquery-or-javascript/#comments Sun, 16 Oct 2011 21:14:56 +0000 Admin https://jqueryplugins.info/2011/10/run-function-based-on-hash-tag-using-jquery-or-javascript/ Post link: Run function based on hash tag using jQuery or Javascript

On my site I have user profiles. Each user profile can have a number of tabs which have a javascript function to show the selected tab and hide all other...

]]>
Post link: Run function based on hash tag using jQuery or Javascript

On my site I have user profiles. Each user profile can have a number of tabs which have a javascript function to show the selected tab and hide all other tabs.

What I’m trying to do is allow a group of users called authors to be able to send a link to their profile and when that profile is loaded, show a specific tab.

Take this user’s profile:

http://www.findyourgeek.com/jasonward

I’d like to let this user link to their reviews as follows:

http://www.findyourgeek.com/jasonward#reviews

I put code in the document.ready function that I thought would work but it doesn’t:

if(window.location.hash.toLowerCase() == "reviews")
{
$  ('#profileAbout').hide();
$  ('#profileInterests').hide();
$  ('#profileOnline').hide();
$  ('#profileArticles').hide();
$  ('#profileReviews').slideDown();
$  ('#profileStatistics').hide();
$  ('#tabsAbout').removeClass('selected');
$  ('#tabsInterests').removeClass('selected');
$  ('#tabsOnline').removeClass('selected');
$  ('#tabsArticles').removeClass('selected');
$  ('#tabsReviews').addClass('selected');
$  ('#tabsStatistics').removeClass('selected');
}

However, when the code runs it does not show the tab. The code that reads the hashtag is correct but it doesn’t run the code below it.

Also, that code is defined as $ ('#tabsReviews a').click() as well.

Any ideas as to why this doesn’t work or any better ideas on how to do it better would be appreciated.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/run-function-based-on-hash-tag-using-jquery-or-javascript/feed/ 0
Dynamic variable in jQuery function parameters https://jqueryplugins.info/2011/10/dynamic-variable-in-jquery-function-parameters/ https://jqueryplugins.info/2011/10/dynamic-variable-in-jquery-function-parameters/#comments Sun, 16 Oct 2011 20:15:36 +0000 Admin https://jqueryplugins.info/2011/10/dynamic-variable-in-jquery-function-parameters/ Post link: Dynamic variable in jQuery function parameters

Let me explain, I’m using the code bellow to initiate a slideshow: target.cycle({ timeout: 0, before: onBefore, after: onAfter, next: target + ', #slide-next', prev: '#slide-prev' }) My only problem...

]]>
Post link: Dynamic variable in jQuery function parameters

Let me explain, I’m using the code bellow to initiate a slideshow:

target.cycle({
            timeout: 0,
            before: onBefore,
            after: onAfter,
            next: target + ', #slide-next',
            prev: '#slide-prev'
        })

My only problem is I’m having trouble defining the next parameter which is supposed to take the selector of the slideshow itself; the variable target and the id of #slide-next

Unfortunately this code does not work, how do I need to define next?

Thank you!

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/dynamic-variable-in-jquery-function-parameters/feed/ 0
Calling jQuery function from C# https://jqueryplugins.info/2011/10/calling-jquery-function-from-c/ https://jqueryplugins.info/2011/10/calling-jquery-function-from-c/#comments Sat, 15 Oct 2011 03:13:59 +0000 Admin https://jqueryplugins.info/2011/10/calling-jquery-function-from-c/ Post link: Calling jQuery function from C#

I have the function below which needs to be called from C# $ ('.image-cropper').each(linkUp); Can anyone explain how it could be done. I tried using the below code String csname1...

]]>
Post link: Calling jQuery function from C#

I have the function below which needs to be called from C#

$  ('.image-cropper').each(linkUp);

Can anyone explain how it could be done. I tried using the below code

    String csname1 = "PopupScript";
    Type cstype = this.GetType();
    ClientScriptManager cs = Page.ClientScript;
    StringBuilder cstext2 = new StringBuilder();
    cstext2.Append("<script type=\"text/javascript\"> $  ('.image-cropper').each(linkUp); </");
    cstext2.Append("script>");
    cs.RegisterClientScriptBlock(cstype, csname1, cstext2.ToString(), false);

but it did not work.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/calling-jquery-function-from-c/feed/ 0
Hijacking onchange event without interfering with original function https://jqueryplugins.info/2011/10/hijacking-onchange-event-without-interfering-with-original-function/ https://jqueryplugins.info/2011/10/hijacking-onchange-event-without-interfering-with-original-function/#comments Wed, 12 Oct 2011 18:15:49 +0000 Admin https://jqueryplugins.info/2011/10/hijacking-onchange-event-without-interfering-with-original-function/ Post link: Hijacking onchange event without interfering with original function

im writing on a library i want to include on different pages who might already use the onchange event – is there any way to attach my event to onchange...

]]>
Post link: Hijacking onchange event without interfering with original function

im writing on a library i want to include on different pages who might already use the onchange event – is there any way to attach my event to onchange without removing the original one?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/hijacking-onchange-event-without-interfering-with-original-function/feed/ 0
What is a good way to transfer function arguments when using selectors? https://jqueryplugins.info/2011/10/what-is-a-good-way-to-transfer-function-arguments-when-using-selectors/ https://jqueryplugins.info/2011/10/what-is-a-good-way-to-transfer-function-arguments-when-using-selectors/#comments Wed, 12 Oct 2011 16:14:49 +0000 Admin https://jqueryplugins.info/2011/10/what-is-a-good-way-to-transfer-function-arguments-when-using-selectors/ Post link: What is a good way to transfer function arguments when using selectors?

I am trying to isolate my HTML from my js by replacing the following <div id = "foo" onclick="bar(variable)"></div> with <div id = "foo"></div> $ (document).ready(function() { $ ("#foo").click(function(event) {...

]]>
Post link: What is a good way to transfer function arguments when using selectors?

I am trying to isolate my HTML from my js by replacing the following

<div id = "foo" onclick="bar(variable)"></div>

with

<div id = "foo"></div>
$  (document).ready(function()    {
    $  ("#foo").click(function(event) {
        bar(???);
    });
});

Now, what would be a good way to transfer the parameter for bar().

Should I merge it with some element id? Or should I declare it as a JS variable using PHP when I load the page? Or is there a better way?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/what-is-a-good-way-to-transfer-function-arguments-when-using-selectors/feed/ 0