English 中文(简体)
• 如何在联合材料中储存A PHP Variable,以便与j Query一起使用?
原标题:How Do I Store A PHP Variable In JS For Use With jQuery?

我很想知道,在什么时候,我会把代码从PHP(在编号班级使用)中选取一个变量,并把它储存在一个能够上网的变量中?

Here is an example:

$(".object1-22").hover(function(e){
    $(".object2-22").show();
}, function(e) {
    $(".object2-22").hide();
});

因此,在我的法典中,我有两个目标。 当你在22个标的1上台时,我想到上只显示22个标的。

How could I perform this task?

最佳回答

如果你为您的物体(22nd instance of Object2")设立身份证,则使用超文本识别码,而不是CSS。

我猜测你想到的是,这些物体在all上采取同样的行为,因此没有为每个物体单独写起事件处理器。 使用共同的CSS类别(object1 object2)和单个IDs(object1-22,object2-22)

Consider

$(".object1").hover(function(e){
    $( #  + this.id.replace(/object1-/,  object2- ).show();
}, function(e) {
    $( #  + this.id.replace(/object1-/,  object2- ).hide();
});

You could even link the related elements beforehand.

$(".object1")
.each(function () {
    this.partner = $(this.id.replace(/^object1-/,  object2- )[0];
})
.hover(function () {
    $(this.partner).show();
}, function () {
    $(this.partner).hide();
});

尽管如此,这是StackOverflow的一个问题,不幸的是,我在这里没有足够回响来照此指出这个问题。

问题回答

难道你会只是重复一下子宫的变数吗? 或者我是否误解了你的问题?

jsVar = <?php echo $phpVar; ?>




相关问题
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.

热门标签