Results 1 to 10 of 13

Hybrid View

  1. #1
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    help question my custom jQuery code does not work, why??

    I have this generated code in zencart which is emplaced by one of the shopping cart files into the shopping cart display (rows):

    <span class="btn btn-primary">
    Check Out
    </span>

    btn-primary class sets the button background color to blue

    I want to use javascript/jQuery to give this button a different background color.
    Please do not tell me change the css, I already know how to do that, it will not do what I need.

    I have this jQuery code in /modules/pages/shopping_cart/jscript_buttons.js:

    ("span.btn.btn-primary:contains('Check Out')").css("background-color", "purple");

    Nothing happens to the check out button, can anyone suggest why??
    I've tried several variations on the span part...

    span.btn.btn-primary corresponds to the styles, contains means it has the phrase 'Check Out', so it SHOULD work but it does not, why???

    Thank you, Tom

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: page-specific javascript does not work, why??

    Don't jQuery statements need to start with $ or jQuery?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    help question Re: page-specific javascript does not work, why??

    Quote Originally Posted by DrByte View Post
    Don't jQuery statements need to start with $ or jQuery?
    Yes, I accidentally dropped the $ when I copy/pasted the line, I cannot now fix it in my original post.

    The statement actually reads as shown below, it is the only line in the js file, I've checked the syntax against jQuery docs.

    $("span:contains('Check Out')").css("background-color", "purple");

    Maybe I am declaring the javascript wrong?? I know the zen cart code itself creates the span...

    Thank you, Tom
    Last edited by tlyczko; 19 Dec 2012 at 09:30 PM.

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: page-specific javascript does not work, why??

    You say the button text has a class tag, which looks like it should be specific enough to identify and control with CSS. Can we see the site? Maybe we can suggest a way to apply styling to it... there are lots of tricky methods that can be used.

  5. #5
    Join Date
    Dec 2003
    Location
    UPstate NY
    Posts
    440
    Plugin Contributions
    0

    Default Re: page-specific javascript does not work, why??

    Quote Originally Posted by gjh42 View Post
    You say the button text has a class tag, which looks like it should be specific enough to identify and control with CSS. Can we see the site? Maybe we can suggest a way to apply styling to it... there are lots of tricky methods that can be used.
    It is not a live site.
    The span class example given above is real html/css code created and applied by ZEN CART APPLICATION CODE, which as many of you know has quite a convoluted route to generating the html/css used by the browser.
    I get no errors telling me why the jQuery code does not work.
    Thank you, Tom

  6. #6
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: page-specific javascript does not work, why??

    The characteristics of the files that create the HTML output are irrelevant to this question. If the site is not live, then posting a good snippet of the HTML page source output for the element in question (showing the container elements for the text, out far enough to identify the location) could help us help you.

    On the off chance that the jQuery you want to use really is needed, telling us more about how you implemented it (and set up jQuery) may be useful.

 

 

Similar Threads

  1. Replies: 5
    Last Post: 22 Nov 2014, 04:26 AM
  2. v150 Custom Sort Order does not work
    By DeepGirl in forum Setting Up Categories, Products, Attributes
    Replies: 8
    Last Post: 6 Jun 2014, 04:22 PM
  3. v150 why does this code not work?
    By nazca in forum General Questions
    Replies: 6
    Last Post: 9 Oct 2013, 02:19 PM
  4. Why Does this SQL not work?
    By plymgary1 in forum General Questions
    Replies: 5
    Last Post: 7 Jun 2011, 11:24 AM
  5. Why does it not work? Please help!
    By pasb in forum Installing on a Linux/Unix Server
    Replies: 3
    Last Post: 22 Jul 2009, 04:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg