English 中文(简体)
如何在 jquery 中点击点击 函数
原标题:How to call onclick function in jquery

我有这样的jquery日历代码

<script>
$(document).ready(function() {
    $( #calTwo ).jCal({
        day: new Date( (new Date()).setMonth( (new Date()).getMonth() + 2 ) ),
        days: 7,
        showMonths: 1,
        monthSelect:    true
    });
});
</script>

在我的身体比赛中

<body>
<span id="calTwo"></span>
</body>

上述代码运作良好,但我的要求是,不要使用跨 ID 标记,我需要使用文本字段,而贴近文本字段的一个日历图像。点击该图像日历应该显示,不管我所选择的日期在文本字段中显示,点击该图像日历应该显示,也不管我选择的日期是什么。

我对Jquery是新来的 不知道该如何执行这个特写 有什么帮助吗?

最佳回答

类似 :

<input id="calTwo" /> <img src="..." id="calTwoIcon" />

<script>
$( #calTwoIcon ).click(function() {
    $( #calTwo ).focus();
});
</script>

您正在寻找的就是这个吗? 我刚刚放置了一个图像, 并指派了一个点击事件, 被调用时会聚焦日历中应该显示日历的输入。 或者您可以做 < code>$ (# cal2). trigger (点击);

问题回答

您也可以使用jQuery UI dateparter

HTML :

Date: <input id="calTwo" type="text"></input>​

标注描述 :

$(document).ready(function() {
    $( #calTwo ).datepicker().option({"setDate": new Date()});
});​

Example: http://jsfiddle.net/YQ7k8/ The example is ugly because jsfiddle doesn t have jQuery UI css. Take a look at http://jqueryui.com/demos/datepicker/ to see how it might look with the right theme.





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

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.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签