English 中文(简体)
如果在初始化职能中指派活动管理员,如何通过论证?
原标题:How to pass argument if event handler is assigned in initialization function?

总是,根据头一本书,在超文本和 Java字之间区分介绍层和行为。

他们告诉我不要做:

<textarea onclick="showAlert()"></textarea>

但如下:

以下例子将行为与超文本(结构)分开。

<html>
<head>

<script type="text/javascript">
window.onload = init;

function init() {
  $( txt_area ).onclick = showAlert;
}

function showAlert(say) {
  alert(say);
}
</script>
</head>
<body>
<textarea id="txt_area"></textarea>
</body>
</html>

这使得超文本(结构)能够看清清洁,而“航空”部分在页数时,先入内功能。 我理解这一点。

但是,我想知道,我为什么要通过一个论点来表明Alert()的职能?

下面不可行,它将在页数上点后立即称为显示器,这不是我想要的,因为它需要发射浮标。

function init() {
  $( txt_area ).onclick = showAlert("hello");
}

是否可以提出论据,以显示行为和结构是否可行?

<>>>>>

不妨提及。 使用原型。

最佳回答

• 履行你的职责。

$( txt_area ).onclick = function() {
    showAlert("hello");
};
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签