Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 有人能告诉我函数是如何针对元素的吗?_Javascript_Jquery - Fatal编程技术网

Javascript 有人能告诉我函数是如何针对元素的吗?

Javascript 有人能告诉我函数是如何针对元素的吗?,javascript,jquery,Javascript,Jquery,我不是Jquery的对手,我需要知道这个脚本中的函数如何知道要修改什么元素 我知道这跟我有点关系 $(function(){ var settings = { objSlideTrigger: '.trigger', // link button id objSlidePanel: '', // slide div class or id } settings.objSlidePanel = "#"+ $(this).data('content') +""; 我只是不知道它

我不是Jquery的对手,我需要知道这个脚本中的函数如何知道要修改什么元素

我知道这跟我有点关系

$(function(){
var settings = {
    objSlideTrigger: '.trigger', // link button id
    objSlidePanel: '', // slide div class or id
}

settings.objSlidePanel = "#"+ $(this).data('content') +"";
我只是不知道它是如何在类面板中定位元素的,如果你理解我想说的话…:/

-试着点击小提琴中的
面板一

这就是选择元素:-

settings.objSlidePanel = "#" + $(this).data('content') + "";
alert(settings.objSlidePanel);
说明:-

"#" + $(this).data('content') + ""    
以这种方式选择元素的ID

  • #

  • $(this.data('content')的值
    =
    面板一
    获取

  • //面板一

    所以字符串集体变成了
    “#面板一”

    ——试着点击小提琴中的
    面板一

    这就是选择元素:-

    settings.objSlidePanel = "#" + $(this).data('content') + "";
    alert(settings.objSlidePanel);
    
    说明:-

    "#" + $(this).data('content') + ""    
    
    以这种方式选择元素的ID

  • #

  • $(this.data('content')的值
    =
    面板一
    获取

  • //面板一


    因此,字符串统称为
    “#panel one”

    ,此行选择元素:

    settings.objSlidePanel = "#"+ $(this).data('content') +"";  
    

    它所做的是获取当前单击的元素
    $(this)
    ,并检查数据属性“content”。。。因为您已经定义了
    data content=“panel one”
    ,例如。。。由于您的
    设置,它将触发具有该id的项。objSlidePanel
    将等于
    “#panel one”

    此行选择元素:

    settings.objSlidePanel = "#"+ $(this).data('content') +"";  
    

    它所做的是获取当前单击的元素
    $(this)
    ,并检查数据属性“content”。。。因为您已经定义了
    data content=“panel one”
    ,例如。。。由于您的
    设置,它将触发具有该id的项。objSlidePanel
    将等于
    “#panel one”

    首先:查看jQuery UI选项卡

    关于你的问题:

    settings.objSlidePanel = $("#"+ $(this).data('content'))
    

    但最主要的问题是如何隐藏之前显示的面板:看看jQuery UI选项卡

    var settings = {
      objSlideTrigger: '.trigger',// link button id
      objSlidePanel: '',// slide div class or id
    }
    
    // basically your script tells you that everything that has a class of .trigger
    // is binded by a click and $(this) is used to access the html or dom that you've binded
    // or that has a click event of that selector
    
    $(settings.objSlideTrigger).bind('click', function() {
    
      // Going back to your question
      // $(this) <--- refers to the one you clicked on <a class="trigger" data-content="panel-#">
      // $(this).data('content') actually gets the data-content attribute of the one you've clicked
    
      settings.objSlidePanel = "#" + $(this).data('content') + "";
    
      // the code above gets the value
      // and now you're using it by
      // $(settings.objSlidePanel) or equivalent to
      // $("#" + $(this).data('content'));
      // or $("#panel-one");
    
    });
    
    关于你的问题:

    settings.objSlidePanel = $("#"+ $(this).data('content'))
    
    但主要问题是如何隐藏先前显示的面板

    var设置={
    
    var settings = {
      objSlideTrigger: '.trigger',// link button id
      objSlidePanel: '',// slide div class or id
    }
    
    // basically your script tells you that everything that has a class of .trigger
    // is binded by a click and $(this) is used to access the html or dom that you've binded
    // or that has a click event of that selector
    
    $(settings.objSlideTrigger).bind('click', function() {
    
      // Going back to your question
      // $(this) <--- refers to the one you clicked on <a class="trigger" data-content="panel-#">
      // $(this).data('content') actually gets the data-content attribute of the one you've clicked
    
      settings.objSlidePanel = "#" + $(this).data('content') + "";
    
      // the code above gets the value
      // and now you're using it by
      // $(settings.objSlidePanel) or equivalent to
      // $("#" + $(this).data('content'));
      // or $("#panel-one");
    
    });
    
    objSlideTrigger:'.trigger',//链接按钮id objSlidePanel:“”,//幻灯片div类或id } //基本上,您的脚本告诉您,所有具有.trigger类的 //通过单击绑定,$(这)用于访问已绑定的html或dom //或者具有该选择器的单击事件 $(settings.objSlideTrigger).bind('click',function(){ //回到你的问题上来 //$(此)
    var设置={
    objSlideTrigger:'.trigger',//链接按钮id
    objSlidePanel:“”,//幻灯片div类或id
    }
    //基本上,您的脚本告诉您,所有具有.trigger类的
    //通过单击绑定,$(这)用于访问已绑定的html或dom
    //或者具有该选择器的单击事件
    $(settings.objSlideTrigger).bind('click',function(){
    //回到你的问题上来
    
    //$(this)settings.objSlidePanel=“#”+$(this.data('content')+”;这对应于选择器设置的生成。objSlidePanel=“#”+$(this.data('content')+”);如果我想以两个元素为目标,例如panel和page wrapper,这对应于Selector的生成。我会像这样将page wrapper类添加到数据内容中。data content=“panel one,wrapper”。或者我需要向一个元素添加多个数据内容吗?因此,您了解我试图实现的目标,每次打开特定面板时,我都需要在高度上扩展包装器div。我得到代码的jist只是不确定它如何与HTMLyou通信需要添加“,#包装器”…因为第二个元素也需要存在id选择器。或者您可以更改代码并将其在“,”上拆分,然后在javascript函数中添加“#”。因此,如果我希望以两个元素为目标,例如面板和页面包装器。我会将页面包装器类添加到数据内容中,如下所示。数据内容=“panel one,wrapper”。或者我需要向一个元素添加多个数据内容吗?所以你知道我想要实现什么,每次打开一个特定的面板时,我都需要在高度上扩展wrapper div。我得到代码的jist只是不确定它如何与HTMLyou通信需要添加“,#wrapper”“…因为第二个元素也需要存在id选择器。或者您可以更改代码并将其在”“上拆分,然后在javascript函数中添加“#”。