1

因此,对于我找到的这个脚本,我正在尝试根据我的需要对其进行调整。

我将其用作我的 html:

<a>What is anewall?</a>
<p class="toggle">anewall reponsitionable matte fabric is made from a 7mm polyester fabric      with an acrylic, removable, pressure sensitive adhesive. This adhesive fabric provides as an excellent material for removing, repositioning, and reusing graphics on most wall surfaces. This adhesive fabric shows off an impressive texture, showing quality, while at the same time maintaining the functional removability feature. Keep the adhesive backing free of dust, fibers, and dirt to extent the life span of this product.</p>

并使用这个 jQuery:

<script type="text/javascript">
// Andy Langton's show/hide/mini-accordion - updated 23/11/2009
// Latest version @ http://andylangton.co.uk/jquery-show-hide

// this tells jquery to run the function below once the DOM is ready
$(document).ready(function() {

// choose text for the show/hide link - can contain HTML (e.g. an image)
var showText='Show';
var hideText='Hide';

// initialise the visibility check
var is_visible = false;

// append show/hide links to the element directly preceding the element with a class of      "toggle"
$('.toggle').prev().append(' (<a href="#" class="toggleLink">'+showText+'</a>)<br />');

// hide all of the elements with a class of 'toggle'
$('.toggle').hide();

// capture clicks on the toggle links
$('a.toggleLink').click(function() {

// switch visibility
is_visible = !is_visible;

// change the link depending on whether the element is shown or hidden
$(this).html( (!is_visible) ? showText : hideText);

// toggle the display - uncomment the next line for a basic "accordion" style
//$('.toggle').hide();$('a.toggleLink').html(showText);
$(this).parent().next('.toggle').toggle('slow');

// return false so any link destination is not followed
return false;

});
});
</script>

它适用于 jsFiddle,如此处所示。

http://jsfiddle.net/nfCCh/

但是我网站上的这些大块文字几乎是“打嗝”。

这可以在这里使用用户名“stack”和密码“overflow”在这里看到。

http://anewall.com/content/11-faq

我真的很感激一些帮助,因为我有点,嗯,一个巨大的 jQuery 新手。:)

谢谢,

卡尔

4

1 回答 1

0

You can fix your issue simply by applying a fixed width to your paragraphs, rather than relying on div.justifiedcustom to constrain the proportions. The JS/jQuery should then be able to better calculate and synchronise the revealing process.

The 'hiccup' is actually the paragraph expanding until it can't get any wider and then suddenly showing you the remaining content. The same 'hiccup' can be replicated in your fiddle just by adding a containing div the same way you have in your main demo. http://jsfiddle.net/nfCCh/1/

于 2013-05-26T00:18:09.203 回答