2012-03-10 45 views
0

我想用cookie中的计算值更新来自输入/文本字段的值。它就像一个迷你本地cookie购物车。 从cookie中保存和检索json是一块蛋糕。 在我的行为中,我无法完成以下工作:Jquery选择器似乎不能在谷歌浏览器中工作

我为输入字段中的每个节点添加了一个类,它的构造如下例所示。

Myid = 'webform_cart_nid_10'; 
formElement = $('.' + Myid); 
console.log(formElement); 

的HTML是相当嵌套,可以看到http://it2servu.be/broodjes/bestellen(如果我可以联系呢?)。 我要更新其值是这样的领域:

<input class="webform_cart_nid_10 webform_cart_nid form-text" type="text" id="edit-submitted-cart-item-cart-elements-10" name="submitted[cart_item][cart_elements][10]" value="0" size="3" maxlength="128"> 

包含在重症DIV-ITIS Drupal的输出。

<div class="page clearfix" id="page"> 
    <div id="section-content" class="section section-content"> 
     <div id="zone-content-wrapper" class="zone-wrapper zone-content-wrapper clearfix"> 
     <div id="zone-content" class="zone zone-content clearfix container-12">  
     <div class="grid-12 region region-content" id="region-content"> 
     <div class="region-inner region-content-inner"> 
      <div class="block-inner clearfix"> 
      <div class="content clearfix"> 
      <div class="node node-webform node-promoted view-mode-full clearfix "> 
      <div class="field field-name-title field-type-ds field-label-hidden"> 
       <form class="webform-client-form" enctype="multipart/form-data" action="/broodjes/bestellen" method="post" id="webform-client-form-5" accept-charset="UTF-8"> 
       <div> 
       <fieldset class="collapsible form-wrapper collapse-processed" id="edit-submitted-cart-item-cart-elements"> 
        <div class="fieldset-wrapper"> 
        <div class="form-item form-type-textfield form-item-submitted-cart-item-cart-elements-10"> 
        <input class="webform_cart_nid_10 webform_cart_nid form-text" type="text" id="edit-submitted-cart-item-cart-elements-10" name="submitted[cart_item][cart_elements][10]" value="0" size="3" maxlength="128"> 
... 

大概这是愚蠢的,我只是不知道它是什么?

+0

你'Myid'变量保存类**!**不管怎么说'$'在您的网站中是'undifined',而不是'jQuery'。 – gdoron 2012-03-11 07:50:25

+0

这只是为了调试问题,不是永久的课程。 我已经重写了脚本。谢谢你的努力。 – 2012-03-13 21:01:47

+0

所以......问题解决了吗? – gdoron 2012-03-13 21:07:29

回答

0

你的问题是与jQuery。如果您在Chrome中打开控制台并键入jQuery,它将返回jQuery函数。如果输入$,则返回undefined。你有某种碰撞导致$不会被设置为jQuery。

+0

正是我的想法。我该如何调试?我能否在我的代码中记录函数,并查看它出错的地方?我会在今天晚些时候尝试!非常感谢! – 2012-03-11 09:57:49

0

使用 “jQuery的”,而不是 “$”

Myid = 'webform_cart_nid_10'; 
formElement = jQuery('.' + Myid); 
console.log(formElement); 

的 “$” 从来没有在Drupal的工作对我来说7.

相关问题