English 中文(简体)
贡献。 Add - 独立开展工作,而不是一起工作
原标题:Attributes.Add - works independently, not together
  • 时间:2009-11-30 16:44:43
  •  标签:
  • javascript

我对同一活动有两个特点:

ddlBuyer.Attributes.Add("onclick", "$( #tbxProdAC ).val( );");

ddlBuyer.Attributes.Add("onclick", "$( #txtbxHowMany ).val( );");

如果我说一句话,则另一条工作罚款。 但是,如果我只离开两条线路,就只发射一条。

一些人可以向我解释这一逻辑,并且进一步解释这一逻辑,我应该怎样做,这样,当德勒·布伊耶尔执行浮标事件时,就会出现高射线事件,既包括 t子。 • HowMany & tbxProdAC回到了价值和价值;

最佳回答

你只能用某个名字添加一个独一无二的属性,因此,你在后面加上第二个名字。 它相当于在超文本标签中拥有两个“立克”特性。 Won t work.

然而,这并不意味着你可以针对某一事件而发射多个功能。 例如,你可以做些什么。

ddlBuyer.onclick = function() {
   //first thing to do
   //second thing to do
};

这样做的另一个方式是使用j Query图书馆;j Query s “bind”的指挥可对单一事件施加多重功能。 这样做的好处是,你不必担心,你重写了在别处添加的具有约束力的活动(上述例子将作此改动)。

问题回答

Try:

/Split Line for Readability.

ddlBuyer.Attributes.Add("onclick", "function(){
    $( #tbxProdAC ).val(  );
    $( txtbxHowMany ).val(  );
};");

或:

ddlBuyer.Attributes.Add("onclick", 
    "$( #tbxProdAC ).val(  );
     $( txtbxHowMany ).val(  );");

不是将硬盘旋功能纳入标记,而是在服务器侧生成客户方代码,约束客户方的立克事件。 也许会有一个像“ j”这样的框架来这样做。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签