2015-06-23 1 views
0

Я скрываю и показываю содержимое внутри поля на клике легенды.Предотвращать нажатие элементов в скрытии и шоу - jQuery

JSFIDDLE Пример

var legends = document.getElementsByTagName("legend"); 

    for(var i=0; i<legends.length; i++) 
    { 
     legends[i].onclick = function() 
     { 
      var myDivs = this.parentNode.getElementsByTagName("div"); 
      var myDiv; 

      if(myDivs.length > 0) 
      { 
       var myDiv = myDivs[0]; 

       if(myDiv.style.display == "") 
       { 
        myDiv.style.display = "none" 
       } 
       else 
       { 
        myDiv.style.display = ""; 
       } 
      } 
     } 
    } 

Как предотвратить Pusing после показа содержимого? В моем примере Пример содержимого отображается после отображения содержимого. Как совместить содержимое div?

ответ

0

Я бы предложил показать его во всплывающем окне, если вы используете jquery. Попробуйте этот код в HTML и убедитесь, что вы ссылаетесь Jquery мобильный:

<a href="#popupBasic" id="tet" data-rel="popup"><legend>One Legend</legend></a> 

<div data-role="popup" id="popupBasic"> 
    <fieldset> 

    <div>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.e</div> 

</fieldset> 
</div> 
<div><text>Sample Content</text></div> 

jsfiddle: https://jsfiddle.net/UHn6q/51/

 Смежные вопросы

  • Нет связанных вопросов^_^