나는이 머리로 내 머리를 때리고 있었고 스택 오버플로와 다른 곳에서 검색했습니다. 내가 찾은 가장 가까운 대답은 Expand Specific Accordion from URL이지만 내 사이트에서 제대로 작동하지 않습니다.JQuery Accordian - URL이 DIV 내에서 DIV를 확장합니다.
다른 페이지/사이트에서 www.xyz.com/page#weather와 같은 앵커로 URL을 입력하고 다른 li의 내부에있는 li를 자동으로 이동하여 확장하게하고 싶습니다. href = # abc에 #abc를 추가 한 다음 포함 된 URL과 유사한 코드를 시도했습니다. 나는 내가 원하는 li에 이드를 추가하려고 시도했다. 아래 코드는 현재와 같이 실제 구조를 기반으로합니다. 나는 도움을 얻을 때 혼란스럽고 혼란스럽고 혼란스럽게 만들고 싶지 않습니다. 나는이 코드를 물려 받았고, 지금은 그것을 철저히 조사하는 것이 선택 사항이 아니다.
제공 할 수있는 도움에 감사드립니다.
페이지 구조는 다음과 같습니다
(function($) {
$.Expandable = function(el, options) {
/**
* Default settings
* @access private
* @type {Object}
*/
var defaults = {
};
/**
* Current instance
* @access private
* @type {*}
*/
var plugin = this;
/**
* Plugin settings, defaults merged with user options
* @access public
* @type {Object}
*/
plugin.settings = {};
/**
* Reference to the jQuery version of the DOM element
* @access private
* @type {Object}
*/
var $element = $(el);
/**
* Reference to the DOM element
* @access private
* @type {Object}
*/
var element = el;
/**
* The control that toggles open/close state
* @access private
* @type {*}
*/
var title = $element.find('>.toggle');
/**
* All pages
* @access private
* @type {*}
*/
var content = $element.find('>.content');
var siblings;
/**
* Constructor
* @access public
*/
plugin.init = function() {
plugin.settings = $.extend({}, defaults, options);
title.on('click', function(e) {
e.preventDefault();
if($element.hasClass('open')) {
content.slideUp('fast');
$element.removeClass('open');
return;
}
content.slideDown('fast');
$element.addClass('open');
});
if($element.hasClass('open')) {
content.slideDown('fast');
}
};
// Call constructor
plugin.init();
};
// Add the plugin to the jQuery.fn object
$.fn.Expandable = function(options) {
// iterate through the DOM elements we are attaching the plugin to
return this.each(function() {
var $this = $(this);
if(undefined == $this.data('Expandable')) {
var plugin = new $.Expandable(this, options);
$this.data('Expandable', plugin);
}
if(typeof options == 'string') {
$this.data('Expandable')[options]();
}
});
}
})(jQuery);
$(document).ready(function() {
$('[data-ui="expandable"]').Expandable();
});
정확하게 일치가 확장되는 방식은 실제로 자체적으로 발생하는 것이 아니며 실제로 accordian을 만드는 코드가 있어야합니까? – adeneo
다른 질문에서 대답을 읽었습니까? 그것은 무엇을 해야할지를 보여줍니다. – Cruiser
Adeneo, 아코디언 용 스크립트가 있습니다. 완벽하게 작동합니다. 이 스크립트를 포함하도록 내 질문을 업데이트 할 것입니다. – HADSTORM