AttributeError: __enter__

这个问题就是在使用 :tensorflow的过程中,

with tf.Session as sess:应该在Session 后面加上括号:

with tf.Session() as sess:

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
=== Simple Tags === Contributors: momo360modena Donate link: http://beapi.fr/donate/ Tags: tag, posts, tags, admin, administration, tagging, navigation, terms, taxonomy Requires at least: 3.0 Tested up to: 3.3 Stable tag: 2.2 Add some tools for taxonomies : Terms suggestion, Mass Edit Terms, Auto link Terms, Ajax Autocompletion, Click Terms, Auto terms, Advanced manage terms, Advanced Post Terms, Related Posts by Terms, etc. == Description == Simple Tags is the successor of Simple Tagging Plugin **This is THE perfect tool to manage perfectly your WP terms for any taxonomy** It was written with this philosophy : best performances, more secured and brings a lot of new functions This plugin is developped on WordPress 3.3, with the constant WP_DEBUG to TRUE. * Administration * Tags suggestion from Yahoo! Term Extraction API, OpenCalais, Alchemy, Zemanta, Tag The Net, Local DB with AJAX request * Compatible with TinyMCE, FCKeditor, WYMeditor and QuickTags * tags management (rename, delete, merge, search and add tags, edit tags ID) * **Edit mass tags (more than 50 posts once)** * Auto link tags in post content * Auto tags ! * Type-ahead input tags / Autocompletion Ajax * Click tags * Possibility to tag pages (not only posts) and include them inside the tags results * **Easy configuration ! (in WP admin)** * Public * Technorati, Flickr and Delicious tags * Dynamic Tag Clouds with colors with Widgets (random order, etc) And more... == Installation == **Required PHP5.** The Simple Tags can be installed in 3 easy steps: 1. Unzip "Simple tags" archive and put all files into a folder like "/wp-content/plugins/simple-tags/" 2. Activate the plugin through the 'Plugins' menu in WordPress 3. Inside the Wordpress admin, go to Options > Simple Tags, adjust the parameters according to your needs, and save them. == Frequently Asked Questions == = Simple Tags is compatible with which WordPress versions ? = * 2.0 and upper are compatible only with WordPress 3.0 & 3.1 & 3.2 & 3.3 ! * 1.7 and upper are compatible only with WordPress 2.8, 2.9 ! * 1.6.7 and before are compatible with WordPress 2.3, 2.5, 2.6, 2.7 * Before WP 2.3, you must use the plugin Simple Tagging. == Screenshots == 1. A example tag cloud (with dynamic color and size) 2. Do you have a not yet tagged blog ? Edit mass tags options is perfect for you : tag 20, 30 or 50 articles with autocompletion in one step ! 3. Autotagging your content ! 4. Add tags easily with click tags ! 3. To help you to add easily tags, Simple Tags has an autocompletion script. When you begin to tape a letter or more, a list a tags appears : you have only to choose ! You can choose the down direction to see all the tags. 6. You also can suggest tags from lot's of service (Yahoo! Term Extraction API, OpenCalais, Alchemy, Zemanta, Tag The Net, Local DB) == Changelog == * Version 2.2 : * Add compatibility with WP3.3 * Move JavaScript register/enqueue to dedicated hook * Version 2.1.2 : * Add some nonces for improve security for settings panel * Version 2.1.1 : * Add a feature that allow deleting rarely used terms. (based on counter term) * Fix bug for allow Suggested Tags for page CPT. * Version 2.1 : * Add compatibility with WP 3.2 * Fix bug with autocompletion. (jQuery want now a strict content type text/plain) * Upgrade JS Libary (jQuery Autocomplete, jQuery Cookie, jQuery bgIframe) * Version 2.0-beta9 : * Fix conflict with plugin using Google Library Javascript for jQuery. Example : "Use Google Libraries" * Add an option for choose input text or textarea for old tags field * Add an option for min chars autocompletion * Version 2.0-beta8 : * Update POT. * Update french translation. * Version 2.0-beta7 : * Add a metabox on write page that allow to deactive autolinks or autotags for a specific post * Add an option for restore old feature "Manage terms" * Add an option for restore old feature "Related posts" * Remove "Clean DB" and "Rename slugs" in manage terms * Remove "include cat" on "Related Posts" settings * Optimize function "Related posts" * Reorganize admin for have a tab features with all features available * Use a input text for Simple Tags autocompletion field * Remove ID of term from autocompletion * Fix autocompletion on mange terms page * Add a field for advanced usage on tagcloud widget * Version 2.0-beta6 : * Add Japanese translation (thanks - kazuhisa) * Fix a bug with search and taxonomy param for mass edit terms. (ticket #233) * Fix a bug with auto tags and whole word option. (ticket #232) * Fix a bug with tag/pages for include pages in WP_Query for a tag * Improve performance of auto link * Fix a bug with max links by posts for auto links * Add an option for choose priority hook of auto links * Version 2.0-beta5 : * Fix a bug and a notice with st_the_tags() that not display any tags... * Version 2.0-beta4 : * Fix a fatal with error with autoterms. * Fix a bug with autoterms when saving post, somes times called twice... * Improve performance when saving posts. * Allow old tags field for each custom post type that use post tags. * Version 2.0-beta3 : * Fix a bug when the st_the_tags() function is called. * Version 2.0-beta2 : * Restore empty templates functions for skip errors * Fix a bug with autolinks * Restore custom post tags feature : st_the_tags() * Fix a bug with widget taxo option saving * Version 2.0-beta1 : * This version is a back to fondamentals. Somes features are removed ! * This version need testing ! * Remove old marker <!--st_tag_cloud--> * Remove related posts * Remove related tags * Remove tags as HTML keywords * Remove nofollow options * Remove custom function for display current post tags * Remove auto-add post tags * Remove embedded tags * Change method for tags for page. * Improve memory consommation : all feature can be deactived. * Improve memory consommation : Stop use class variables for options * Support mass edit with CPT/CT * Improve AJAX call by using WordPress hook * Version 1.8.1 : * Improve uninstaller * Improve code widgets * Improve support of custom taxonomies for simple tags features * Version 1.8.0 : * Compatibility 3.0 * Add an option for auto-tags * Remove somes notices * Fix a bug with tag cloud and empty terms * Fix a bug with comma on font-size CSS depending locales * Version 1.7.5 : * Fix a bug with auto links terms. (type input) * Fix cache conflict key * Fix a opencalais bug on firt pass integration * Fix a bug with limit days/category filter for tag cloud. * Fix javascript autocomplete for allow enter new tag. * Re-add list of tags on manage page. * Version 1.7.4.4 : * Fix a stupid during the first activation. (PHP4/PHP5) * Version 1.7.4.3 : * Fix a bug with PHP 4.4 and plugin activation. (PHP4 suck...) * Remove base class for compatibility PHP4. * Fix sanitized HTML on admin. * Fix random order for tag cloud. * Try a fix for support WP-O-Matic cron. * Version 1.7.4.2 : * Updated Traditional Chinese translation (thank to Neil Lin) * Fix a bug with selector taxonomy and user taxonomy. (thank to Nicolas Furno) * Version 1.7.4.1 : * Updated italian translation * Fix a bug with old random value for widget/tag cloud call (thank to [email protected]) * Version 1.7.4 : * Release of version 1.7.4, to avoid confusion with the borked version 1.7.2 published in error. * Externalize options array on external file for diminue memory consommation. (call only on options page) * Fix importers embedded tags * Version 1.7.2 : * Add taxonomy support * Rewrite manage page * New JS for autocomplete, use AJAX for better performance * Fix PHP4. * Fix bug with Yahoo API/Tag the net for long post * Add OpenCalais, Alchemy and Zemanta (first pass, API offers much more possibilities!) * Version 1.7.1-rc1.2 : RC 1.2 (this version must be test !) * Fix compatibility PHP4 * Version 1.7.1-rc1.1 : RC 1.1 (this version must be test !) * Fix a bug with activation hook. * Version 1.7.1-rc1 : RC 1 (this version must be test !) * Somes ajust for Wordpress 2.9 * Remove 99,99% notices PHP from ST * Clean some part of the plugin. * Version 1.7.1-a1 : Alpha 1 * Check compatibility WP 2.9 ( fix somes UI bugs ) * Fix a bug with save Widget options * Version 1.7b1.1 * Add exclude option in auto tags link. * Version 1.7b1 * Add compatibily WP 2.8 * Remove support old WP versions * Change some things on architecture for optimize performance on admin. (stop copy class variables) * Use new API for Widgets * Use new API for Taxonomy * Remove somes "notices" PHP * Fix old cache method. * Version 1.6.6 * Add Belorussian translation * Version 1.6.5 * Fix redeclare class "Services_JSON_Error" bug * Version 1.6.4 * Fix a stupid bug with JavaScript add tags. * Version 1.6.3 * Fix a small bug with JSON class. * Version 1.6.2 * Click tags and suggested tags can work with default WordPress Tags. * The Simple Tags auto completion replace default WordPress Tags input. * Restore administration options. * Better management of Simple Tags with WP_Scripts and WP_Styles * Add an option for auto link tags. * Fix a potential error with compatibility old markers. * Update french and chineese translation. * Version 1.6.1 * Fix a JavaScript error for Suggested Tags. * Version 1.6.0 * Add compatibility with WordPress 2.7, use new API for HTTP and Admin. No new features ! * Version 1.5.7 * Move autolink after ShortCodes * Add Italian and German translation * Fix a potential bug during the plugin activation. * Version 1.5.6 * Improve performance of MetaKeywords and Autolink * Conform HTML W3C * Version 1.5.5 * Restore full manage page * Fix duplicate tags for click tags and autocompletion * Lot's of optimization... * Update translations * Add spanish translation * Version 1.5.3 * Fix counter for tags. (you must re-save your posts) * Update translations (ja, ru) * Version 1.5.2.1 * Fix internationalization with Gengo * Update zh_CN translation * Version 1.5.2 * Fix widgets * Edit priority * Fix internationalization * Version 1.5.1 * Wait plugin_init for start ST :) * Version 1.5 * Add compatibility with WordPress 2.5 * Version 1.3.9 * Fix nofollow rel feature * Remove warning with keywords feature * Version 1.3.8 * Fix internationalization when reset plugin options (and installation) * Fix auto link feature (word replaced keep original case) * Version 1.3.7 * Improved performance of Simple Tags (specially Related Posts) * Version 1.3.6 * Fix auto tags with all DB and this feature work also for auto tags save feature * Clean lot's url * Update japan language * Version 1.3.5 * Add an option for auto link case * Fix rel HTML for auto link * Restict tag cloud for published tag (exclude programmed) * Version 1.3.4 * Fix autolink (new algo) * Version 1.3.3 * Fix link to new page * Update languages * Version 1.3.2 * Update japan translation * Version 1.3.1 * Plugin compatible with mu-plugins without modifications (NOT TAGS SITE WIDE) (for truth !) * Include categories into Tag Cloud and Tag list * Improve performance with a better WP Object Cache management * Add a global option for rel="nofollow" attribute * Add an option to limit keywords in HTML header * Desactivate keywords generation if All In One SEO Pack is actived. * st_the_tags work outside loop now... * Add an option to uninstall all ST options * Add 2 options for auto tags features * Fix javascript autotag features * Fix lot's bugs in admin ;) * Version 1.3 * Plugin compatible with mu-plugins without modifications (NOT TAGS SITE WIDE) * Fix auto link tags now working without meta-keywords * New parameter for auto link tags (min usage) * Fix auto link PREG_REPLACE error. * New parameter for related posts (min tags shared) * Add marker %post_title_attribute% for related posts, to use into title attribute * Add Related Tags * Add Remove Related Tags * Fix alphabetical order in tag cloud with accent * New interface for Tags options, more options for easily configuration * AJAX admin * AJAX Pagination for Manage Tags pages * Fix excessive memory consomation * Tags suggestion from Yahoo Term Extractions API, Tag The Net and Local Tags with AJAX request * Compatible with TinyMCE, FCKeditor, WYMeditor and quicktags * Click tags with AJAX request * Preview color in Tag Cloud Admin Options * Version 1.2.4 * Fix a bug with inline tags post * Version 1.2.3 * Fix Widgets Order/Selection * Improve auto link feature * Add a param to desactive font-size during tags cloud generation * Add a param "min_usage" to display a tag in tags cloud * Smallest size and largest size can be the same... * Update translation * Version 1.2.2 * Add more options for inline related posts / tags * Fix empty title bug * Add maximum param for the function st_the_tags() * Update translation * Version 1.2.1 * Fix limit for tag cloud * Version 1.2 * New features * Auto link tags in post content * Auto tags (new and old content) * Importer for embedded tags * Tag Cloud * Fix Tag Cloud Widgets * New way for order tags cloud ( 2 steps ) * Allow embedded tag cloud * Add tag cloud for a specific category * Related Posts * New options for automatic insertion * Add a marker for post_excerpt * Fixed display nothing when no related posts * Current tags posts * New options for automatic insertion * Administration * Check WP version * Mass edit tags improved (search terms, filter untagged) * Removed untagged page * Improve special characters management (& ...) * Uniformize alert message * Autocompletion improved ! * Others * Improved plugin cache * Version 1.1.1 * Fix compatibily with MySQL < 4.1 (Marker "related_tags" of Related Posts is desactived.) * Version 1.1 * Fix XML-RPC and Embedded Tags * Improve compatibility JS with others plugins (calendar) * Minor improve in administration (order keeping on update) * Cleaner for empty terms * Add limit days for Tag Clouds and Related Posts * Add the marker: %relatedtags% for Related Posts => Display tag shared between 2 posts. * True random for tag cloud * Tag cloud can generate class level for CSS size/color * Add Order to Tag Cloud Widgets * Add 2 functions * st_meta_keywords() : Display keywords for manual insert in header * st_the_tags() : Improved the official the_tags() functions. * Add marker for Technorati, Flickr and Delicious * Version 1.0.4a (1.0.4a fix a small bug introduced in 1.0.4) * Update 3 translations for 1.0.4 * Add Japanese translation * Fix "exclude tags" in related posts * Version 1.0.3 * Add 3 translations (german and chineses (zh_TW and zh_CN)) * Fix a potential bug with posts relateds and WP Object Cache * Fix a bug with autocompletion JavaScript (tag not escape) * Possibility to customize date format in related posts * Optimization in meta keywords * New markers to related posts (see advanced usage), old markers are still available * Version 1.0.2 * Keywords * Fix a rare bug with problem encoding * Delete duplicate keywords * Related posts * Possibility to randomize post * New class for tag UL: "st-related-posts" * Tag cloud * Possibility to randomize tags * New class for tag UL: "st-tag-cloud" * Administration * Use WP roles instead old levels * Possibility to order "Mass edit Tags" by Date or ID * Counter now works on "Untagged" page" * Fix one bug on Mass Edit Tags, he was impossible to delete all tags for a post. * You can desactivate Widgets without have a fatal error * Version 1.0.1 * Fixes 2-3 minors bugs * Version 1.0 * Initial version == Upgrade Notice == Nothing to say...
******************************************* ************ WPTOOLS 6 History ************ ********** http://www.wpcubed.com ********* **** Copyright (C) 2012 J. Ziersch and **** **** WPCubed GmbH, Munich, Germany ******** ******************************************* * - = bug fix * + = new feature * * = changed, expanded feature ******************************************* * IMPORTANT: Please edit file WPINC.INC to * activate WPREPORTER, WPSPELL, wPDF, TBX * and GraphicEx / PNGImage support! * Delphi 2009 and later as inbuilt PNGImage ******************************************* * THE MANUAL (PDF) AND REFERENCE (HLP,CHM) * ARE PROVIDED AS SEPERATE DOWNLOADS! ******************************************* ~~~~~~~~~~ Important Notes ~~~~~~~~~~~~ - With Delphi XE2 or XE3 it is possible to compile WPTools into a 64 bit applications. You need WPTools 6 PRO or WPTools 6 Premium for this. - Localization and Inch/CM selection see http://www.wpcubed.com/manuals/wp5man/index.html?localization.htm Also see demo\tasks\localization. There are the required XML files. - if flag wpDontAddExternalFontLeading is active in property FormatOptionsEx the text will be formatted more like WPTools4/MS-Word. You can alternatively set global variable WPDoNotAddExternalFontLeading := TRUE and select the Printer WYSIWYG mode: TWPRichText1.HeaderFooter.UpdateReformatMode(true) - The FormatOption wpDisableAutosizeTables can be required for good display of tables. wpNoMinimumCellPadding for narrow layout, too. - If you plan to use DBWPRichText please check http://www.wpcubed.com/forum/viewtopic.php?p=3456 - The reader/writer receive their options through "FormatStrings" please see list at http://www.wpcubed.com/manuals/formatstrings.htm - WPTools is configured using the file WPINC.INC, here WPREPORTER is activated and the optional WPShared, WPSPell and wPDF can be selected to be compiled into main WPTools package. - also see FAQ: http://www.wpcubed.com/forum/viewforum.php?f=15 - and support forum: http://www.wpcubed.com/forum/ - WPTools 6 PRO and PREMIUM will be compiled as Version 5 if $define "WP6" is not set ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We recommend to use TMS components to create modern user interfaces, toolbars and ribbons. 19.2.2013 - WPTools 6.29.1 - fix in rtf writing code to solve problem with merged cells - fix possible rangecheck error - fix problem with TextObject.LoadFromFile and Delphi XE3 * RTF reader now handles UNC file links which use "\\" in the path * the cursor was not painted if DoubleBuffered was set to true for the parent of the editor + WPTools Premium: Saves and loads \column * improved theming of TWPToolbar and TWPToolPanel + new event: OnPaintDesktopBackground. It can be used to draw the parent of the editor, for example if it is a TMS panel or pager control. Example: procedure TForm1.WPRichText1PaintDesktopBackground(Sender: TObject; Canvas: TCanvas; R: TRect); begin // This would paint the TWPRichText, too - but TWPRichText is locked for repaint during this event AdvOfficePager1.PaintTo(Canvas, -WPRichText1.Left, -WPRichText1.Top); end; - HighlightTextColor can now also be used if 2Pass Painting is used 21.12.2012 - WPTools 6.29 - images in RTF label were not painted when label was moved + added support for XE3 to WPTools STD edition * stream RTFvariables were not loaded from WPT format. They are loaded now. 9.11.2012 - WPTools 6.28 - Update to RTF reader to load landscape flag for sections better - when page mirror was used, after a page break the text indentation was sometimes wrong - hyphenation code was broken - workaround for word files which have space characters in table definitions 16.10.2012 - WPTools 6.27'' * some additions to the PRO edition for XE3 26.9.2012 - WPTools 6.27' * The PRO Version now supports Delphi XE3 3.8.2012 - WPTools 6.27 - fix for wrong display of tables with header and footer rows. Sometimes both were painted without any data. + to load old Hiedit templates as RTF code use the formatstring -HiEditFields. This will create merge fields for ALL fields. - NL sign was not shown right after CTRL+ENTER was pressed (requires ShowNL) - fix for rangecheck exception with paintpages array - fix for footer and page mirror - doubleclick word selection now stops at NL - Workaround for Windows Spooler problems - some images would get lost - sections use footer and header of previous section, not general - ASetBorder did change all border types 12.3.2012 - WPTools 6.25.4 * allows changing of column width in redonly editors. Can be switchoed off in EditOptions or set compiler define TOTALREADONLY + wpDisableSelectAll in EditOptionsEx2 * changed reformat/repaint after Undo/Redo - pro and premium: Due to a problem with precompiler cursoir selection did not work correctly 8.3.2012 - WPTools 6.25.3' - borders for paragraphs with multiple lines were not drawn correctly - change in DBWPRich.pas to use LoadFromString instead of Text - fix possible range check error - change in WPTbar.pas to use different default for BevelOuter - change in WPIOHTML to use default charattr of paragraph is a paragraph is empty 9.2.2012 - WPTools 6.25.2 * new 2-pass painting triggers CustomPaint event only on second loop (when the text is painted) * changed protection of empty paragraph to WPTools 5 way + inside of the OnPrepareImageForSaving event it is now possible to set Writer.CurrentImageName to the name of the file which should be saved. This is only useful if ObjRef = nil and so no ObjRef.Filename can be set. + TParagraph.GetSubText now has optional parameter to disable the object reference char codes #1, #2 and #3 * HTML writer ignores #13 codes when writing the text. * additional savety code in HTML writer * HTML reader sets image width and height to contents, (if possible) * HTML reader: changes UTF8 handling for UTF8Sequence=1 * HTML reader does not stop on \0 anymore * HTML writer writes img tag also for empty images IF a name is provided in event PrepareImageforSaving * HTML reader does not add space at end anymore - the UNICODE reader uses attribute of current paragraph. This is important for consistent behaviour between ANSI and UNICODE version - when writing HTML background color is not set to white when shading is 0. 0 is treated as default value. - image align center and right now works in HTML - fix an endless loop when image was too large - improvement of table border drawing - improvement for right align in table cells + numbering will be used when wpFormatAsWebpage was set in AsWebpage 10.1.2012 - WPTools 6.25 + HTML reader reads cell heighs - RTF writer writes background color easier to understand by Word * improved XML reader/writer (unit WPIOXml1) * improved word wise cursor movement when fields are used + new "paint attributes" mode. Use WPRichText1.BrushStart to select this mode. - dashes were not painted using the current font color - some stability improvements 7.11.2011 - WPTools 6.22 + procedure TParagraph.CellSelectionAdd; + procedure CellSelectionRemove; + EditOptionsEx2: wpCellMultiSelect - allows multiselection in tables when CTRL is pressed + improved XML import/export (unit WPIOXML1.PAS) - some smaller bugs fixed 3.11.2011 - WPTools 6.21.2 - fix problem with TWPToolButton - improved HTML writer to write parameters in "" - improved display of arabic text 24.10.2011 - WPTools 6.21.1 - fix problem when painting insertpoints after tab stops. They were painted two times. - fix in XML and HTML writer. Close tags when extracting text from fields 19.10.2011 - WPTools 6.21 + CodeLocate can now also accessed in non-visual TWPRTFDataCollection and not just TWPCustomRtfEdit + CodeSelect can now also accessed in non-visual TWPRTFDataCollection and not just TWPCustomRtfEdit + TWPRTFDataCollection.CodeLocatePair( FormatName : String; var spar, epar : TParagraph; var spos, epos, : Integer ) :Integer; - solves problem with integrated Bin64 decoder + DeleteField now has optional "Contents" parameter to delete a certain field with contents + the text writer now understand the option -softlinebreaks to create a \n at the end of every line. In fact all soft line breaks will be handled like the #10 code. + CodeLoadSaveEmbeddedText - load or save text in fields, bookmarks, hyperlinks + the regular save and load methods (LoadFromFile, SaveToFile) can now access text wrapped by paired objects. specify the fieldname in the format string, i.e. "f:name=RTF" to save or load the contents of the field "name". + There is an overloaded LoadFromString which expects a WideString as parameter (Delphi 6+) - The Setup named the Delphi 2009 files "Delphi 2005" due to a typo. (Delphi 2005 units are not included anymore) - fix probable range check error in WPRTEDEFS 13.10.2011 - WPTools 6.20 + completely new setup procedure. The PRO and Premium releases don't include object files which makes them much smaller. * compiled new WPTools 6 Reference (CHM file) * Delphi XE2: several small changes to improve theming support * Delphi XE2: several small changes to provide compatibilty to 64bit compiler (requires WPTools PRO) + new demo developed with Delphi XE2, showcases actions, splitscreen, simulated MDI and property dialogs (Demos\XE2\WPWord) + wpDeleteAtEOFRemovesSpaceAfter in EditOptionsEx2 - TextObjectsGetList did not work * WPRuler uses Delphi XE2 VCL Theme plus * added defaults to properties TWPRichText - change in RTF reader to let section inherit the default layout, not the current page layout - fix of problem with table borders when also PageMirror was used. * change to DeleteMarkedChar. It now has additional parameter DeleteEmptyParAndTables : Boolean * change in unit WPWordConv to handle RTF as DOC files if they do not start with "{\rtf" * updated border dialog TWPParagraphBorderDlgEx * updated border drawing code - now supports dotted lines with wider lines. * modified method DeleteColumn * modified WPT reading code to repair table width which were negative + improved image rendering code for transparent (PNG) images. They will be drawn transparently also when scaled and also in high resolution rendering mode. + new code to draw dotted lines which also supports wider lines + new function WPReplaceTokens (unit WPUtils.PAS). It is a ReplaceTokens function to be used on a TWPRTFDataCollection, not TWPRichText - WPPremium - fix problem when there were too columns * MergeText now restores before Merge Cursor position and selection (except for cell selection) * resizing a table column does not move the cursor to the nearby cell anymore * different frame line when resizing columns and rows + InsertColumn now also works if wpAllowSplitOfCombinedCellsOnly was used in EditOptionsEx + new event OnPaintTextFrameRect let you paint background and borders for text frames, i.e. the text body or, with WPTools Premium, custom frames. + WPPREMIUM: In OnMeasureTextPage it is possible to set columns for certain pages. Using PageInfo.colflags=1 it is possible to activate a line between the columns It is also possible to add custom frames using PageInfo.rtfpage.AddFrameRect. + new ViewOptionEx: wpHideParBordersBeforAndAfterPageBreaks + improved paint routine now avoids clipping of characters which were overlapping their bounding box, such as italic letters or "f". The improvement is especially visible when selecting text or using character background colors + WPPREMIUM: it is now possible to print a line between columns using wpShowColumnCenterLine in ViewOptionsEx + With WPTools Premium it is now possible to print a line between certain colums - use par.ASet(WPAT_COLFLAGS, WPCOLUM_LINE); + paragraph styles can now contain border definion for paragraphs + TWPTextObjList now has a IndexOfSource function and a Source[] string array to access the objects * revised code to draw double borders - always draws twou lines on screen even when zoomed * improved saving of numbering attributes with styles * style dialog can now apply number level even if style does not have numbering yet. * revised wpNoEditOutsideTable - was not checked for keyboard input * fix problem with - - - - - at end of line - fix problem with spell-as-you go after hyperlinks - fix problem with page numbers in sections when tables were spanning pages - fix problem with right aligned negative numbers in merge fields * automatic text attribute was not inherited to tables inserted in fields * images with mode "under text " can now be also clicked at positiones where there is no text. - WPLngCtr now defines DONT_OVERRIDE_COM, that fixes the IDE problem with DevExpress Toolbar controls 18.7.2011 - WPTools 6.16.2 * ObjectMode wpobjPositionAtCenter can be used to aligh character based images to the center line. (Other RTF reader will not understand this feature) * some changes to prepare 64bit compatibility (requires WPTools 6 PRO) 7.7.2011 - WPTools 6.16.1 * change to avoid flickering when doing auto scroll * message strings are now loaded from resource strings - modified DBCS support for RTF reader * outerborder action now works for sinle cells and paragraphs 15.6.2011 - WPTools 6.16 + Many improvements to new Border Dialog. It is now possible to apply borders and colors to odd and even rows only. * RTF reader defines symbol IGNORE_AUTOWIDTH_TBL. This disable the Word2010 auto width columns which are not read correctly. Reason: Word 2010 seem to always add an empty column to the end. + using WPRichText1.Caret.Blink:=true it is possible to activate the blinking caret (0.5sec interval). * updated actions to apply inner and outer borders to selected cells * update to ExSymbolDialog, Tab and Table dialog - improved WPTOOLS reader to read and apply outline properties to current outline setting (unless wpLoadDoesNotOverride is used) - wpsec_ResetPageNumber flag is now saved in WPTOOLS format * tripple click in margin selects paragraph + double click in margin selects current cell + tripple click in margin selects current row - change for PaintEngine and TWPRichTextLabel to not shrink tables which are small enough to fit the page This solves a problem with dissapearing text in WPRichTextLabel - fix selection problem when several images were linked to same paragraph - when moving images the Z order will not be reset - HTML Writer: A style with name "DIV" will be added to the style sheet to save the default font - HTML Writer: BaseFont tag will now be written with font size (requires -writebasefont option) - improved display of character background color for fields and other special code - Saving a style sheet did not work with Unicode Compiler 8.5.2011 - WPTools 6.15 * updated border painting * updated Inner/Outer Border Action * new object sizing routine lets the user make the size larger than the page - update in WPTools reader to overwrite outline styles when loading tzhe same group 9.3.2011 - WPTools 6.14.6 * change in format routine to fix problem when a nested table cell caused a page break. 14.12.2010 - WPTools 6.14 * fix for SetAsString code (Unicode Delphi) * several fixes and updates in editor * WPTools Premium: $define DONT_AUTOENTER_TEXTBOXES in WPINC.INC to switch of the behavior, that when editing a textbox the user can click on any other and edit that. 22.9.2010 - WPTools 6.13.3 * WPCtrMemo.PAS now defines TEXT_IS_UNICODE fro Delphi 2009 and later. Now the property Text and SelText reads and writes unicode strigs * change in RTF reader to read ANSI characters in the range 128..255 * Tables and rows can now be hidden. (TParagraph.Hidden) * The Lines property now supports unicode strings (Delphi 2009 and later) + HTML reader and writer now use the entitly ­ as soft hyphen 27.8.2010 - WPTools 6.13.2a + new ViewOptionEx wpUnderlineWebLinks. If active links like http://www.wptools.de will be drawn using the attributes for hyperlinks The HyperlinkCursor will be selected and the hyperlink event will be triggered * other fixes in RTF engine - Memo._OverrideCharset was not set to -1 27.7.2010 - WPTools 6.13.1 + WPRichText1.Memo.ColorGridLines can be used to change the color of the grid lines (ViewOptions) 23.7.2010 - WPTools 6.13 * several improvements of editor * improvement to RTF writer to when writing table cells * improved right aligned text * fixed problem with line heights of lines which are empty except for new line character 22.6.2010 - WPTools 6.12.1b - fix for problem when pressing Accent + Backspace - fix for WPReporter to assign default attribute to destination - fix for WPReporter to move images when converting templates 18.6.2010 - WPTools 6.12.1a * the new border dialog now reads the current border attributes from table cells, tables or selections - Premium: fix problem when loading columns which started on first line - fix in wpfUseKerning mode (FormatOptionsEx2) - it did not work as expected with some texts (We recommend to use wpfUseKerning - it produces better print quality on screen) * Pasting of HTML now works better - fix for right tabs when also borders were used 13.6.2010 - WPTools 6.12 + all new, powerful yet intuitive Border dialog. The border dialog can modify a range of selected cells, columns, rows, tables and also only modify certain properties while leaving the others unchanged. You need to activate the compiler symbol NEWBORDER to use it by default + new method: procedure SetBorderProperties(Inner, Outer: TWPTextStyle; ApplyMode : TWPParagraphBordApply; Mode : TWPUpdateBorderProperties = [wpSetBorderFlags, wpSetBorderType, wpSetBorderWidth, wpSetBorderColor, wpSetParColor, wpSetParShading]); This method is mainly used by the new border dialog. + new flags in ViewOptionsEx: wpShowCurrentCellAsSelected, // Displays current cell to be selected. Disables current selection wpShowCurrentRowAsSelected, // Displays current table row to be selected. Disables current selection wpShowCurrentTableAsSelected // Displays current table to be selected. Disables current selection + new property YOffsetNormal to defined an upper border for normal and wordwrap view. * feature Header.MarginMirror changed to work like MS Word new flag: wpMarginMirrorBookPrint in FormatOptionsEx2 to enable the previous logic * workaround for MouseWheel UP beeing triggered too often (10 mms check) + ClipboardOption wpcoDontPasteHTML to disable HTML pasting completely (avoid problems with firefox) + it is now possible to load base64 embedded JPEGs from HTML * it is now possible to change width of tables which exceed right margin - fix bug in HTML writer for lists in table cells - fix in RTF writer to write character colors also for text which is using a character style - fix: numbering was not always updated - fix: better use fonts in certain RTF files written by MS Word + Update to WPLanguageControl to make Localization easier to use. Only< this code is not required: procedure TForm1.WPLanguageControl1Loaded(Sender: TObject); begin WPLangInterface := TWPLocalizationInterface.Create(WPLanguageControl1); WPLocalizeAllStrings; end; 6.5.2010 - WPTools 6.11.2 * improvement to border rendering * improvement to XML unit WPIOXML1 (Premium) 5.5.2010 - WPTools 6.11.1 + ConvertTableToText now supports option to also handle soft line breaks - fix problems with underlines at end of line - fix problem when loading hyperlinks in RTF - fix problem when saving attributes to XML (WPTools Premium) - fix problem with text rendering - fix problem with tables which habe header row and pages with different header margin 19.4.2010 - WPTools 6.11 + EditOptionEx: wpRowMultiSelect + new event: OnInternPaintPar + new event: RTFDataCollection AfterApplyUndoObject 14.4.2010 - WPTools 6.10.6 * fields are now passed as unicode strings to PDF exporter * Delphi 2010/2009 import has been improved to load unicode values which are stroed in fields. 5.4.2010 - WPTools 6.10.5 + flag: wpDontExtendSelectionToRightMargin. Do not extend selection to end of line + wpInvertActiveRow in ViewOptionsEx - some fixes for Delphi 2009 and Delphi 2010 - fix for section support - WPTools premium: Fix for images in text boxes - workwaround to load RTF which use emfblib for pngblib 28.2.2010 - WPTools 6.10 - improve word left/right movement to skip hidden text - improve http load of images - improve support for numbering - improve saving of character style attributes 11.2.2010 - WPTools 6.09.1 + LoadFromString now has a "WithClear" parameter - fix in RTF reader to better load files which do not define codepage - fix in paint routine to solve a rare lockup - fix in format routine to improve section support 6.2.2010 - WPTools 6.09.1 - fix of problem in save routine when footnotes were used (WPTools premium) - fix in HTML writer - Image optiions now have a Rotation property which allows 90, 180 and 270 setting. - HTML reader and writer now support different colors for left,right,top, bottom lines 1.2.2010 - WPTools 6.09 - HTML writer will write 8 hard spaces for TAB stops at the start of a paragraph - HTML writer will write page information only if -PageInfo was used in format string - fix problem with left aligned text and image wrap around (wrong alignment) - fix problem with sometimes duplicated images in PDF export - fix problem with black rectangle in first line under Windows 7, 64 bit - Improvment to RTF reader to ignore section properties which are not followed by \sect 14.12.2009 - WPTools 6.08 - graphics are resized to fill text area - fixed problems in numbering - fixed problem with one word paragraphs in justified paragraphs - other improvements in editor 27.10.2009 - WPTools 6.07 - fixed one leaking TList per TWPRichText * improved layout of most important dialogs * improved extended insert symbol dialog - fix in RTF reader to load sections and header+footer written by Word 2003 - don't add unwanted cell padding when loading table cells - fix in WPTools reader to read custom number styles - if paragraph styles use number styles the indent defined in the style has priority over numberstyle - LabelDef now also works for one row and one column - better handling of mousewheel event - fix for tabs in tables + GIF animation (requires GifImage) library (not threaded) to use it You need to set ViewOption wpUseOwnDoubleBuffer and call the method RefreshAniImages using a timer object. - fix problem when sections were used with LabeDef.Active = true * change in HTML writer to close tags before paragraph end 4.10.2009 - WPTools 6.06 - fix problem with Delphi 2010 support (language control) - fix problem with PDF export to reduce PDF size - improve support for IME * improve AsWebPage format mode. Now WordWrap propery is supported. - fix searching text upwards with "Whole Word" selected + RTF writer now can use format option "-writehighlight" to writh \highlight instead of \cb 14.9.2009 - WPTools 6.05.9 + added Delphi 2010 Support - problem when pasting from "The Bat" - fix problem in Delphi 2009 (Assign Method) 3.8.2009 - WPTools 6.05.8' * when using "Delete All" in the tabstop dialog, all tabs will be cleared added to manual: Tabstop Category - fixed problem when deleting text in a paragraph. The alignment was cleared unexpectedly. - fix problem with installer, WPMangeHeaderFooter.DFM was not included - fix for IPara in mail merge field objects - improved handling of hoover effect for hyperlinks - improved text rendering for wPDF output (CID Mode) - add correct WPManHeadFoot.dfm 23.7.2009 - WPTools 6.05.7 + WRITE_PROP_WPTOOLSOBJ $define in WPIOWriteRTF. Avoid problems when saving RTF and opting in Word In case of special objects, such as SPAN codes, \*\wpfldinst is beeing written what is ignored by WOrd + Dialog HeaderFooter can optionally create and manage header&footer for the current section + new KeepN Handling. This is by default activated in FormatOptionsEx2 + new wpfHideParagraphWithHiddenText in FormatOptionsEx2. Now paragraphs will be hidden if empty or only contain hidden text. + new format option -zap1 will remove the every first byte to convert a two byte stream into singly byte -zap2 will remove every second byte. Usie this option when loading data from unicode data sets - bugfix for table loading in RTF 15.7.2009 - WPTools 6.05 + TParagraph.Trim method to remove white spaces at start and end + Vertical Scrolling by pressing the middle mouse button now works. + improved auto thumbnail mode * enhancement to HTML reader / writer to handle embedded SPAN objects + new method: ApplySPANStyles(and_remove : Boolean=false; ignore_charattr : Boolean = false); can be used to apply SPAN styles to the text which it embeds + The function InputSpanObjects( Attributes : TWPAbstractCharAttrInterface ) : TWPTextObj; can be used to wrap the selected text into SPAN objects + method LoadCSSheet can be used to load paragraph styles in CSS format from a string - fix problem with Wordrwap and centered text + new even OnTextObjectMovePosition (move event) - OnTextObjectMove is still used for resize (unchanged) 28.6.2009 - WPTools 6.04 + WPTools Premium: Column Balancing * many improvements in RTF reader. Word documents are now understood better * Improvement in check for protected text (ppMergedText) + new ViewOptionsEx property - auto hyperlinks were not working + TWPComboBox has an event OnUpdateItems which will be triggered after the items had been automatically assigned. 24.6.2009 - WPTools 6.03.6 * thinner page borders in thumbnail mode. ViewOptionsEx: wpAutoThumbnailMode will show pagenumbers only when in thubmbnail mode (= wpShowPageNRinGap in ViewOptions) + property ColorDesktop and DeskGradientHorizontal to render the background with a gradient fill * fix for protected text handling (CR after a field) * fix for text alignment near a movable image - EditOption AutoDetectHyperlinks was not working anymore * WPReporter: SuperMerge.Stack.PageBreakAFterGroup := true was ot working when footers were used 1.6.2009 - WPTools 6.03.5 - fix problem with display of character attributes when attributes were inherited from paragraph styles - fix problems with selection deletion in single column, single row tables - improvement of RTF writer when writing sections 11.5.2009 - WPTools 6.03.3 - improved report band dialog, new ShowOptions property - fix in RTF reader to load header/footer - change in HTML writer to save SPAN instead of FONT tag - several fixes in editor * WPTools Premium: better column support. Fixed column height now splits correctly on 2 pages. 28.4.2009 - WPTools 6.03.2 - fix problem with justified text in PDF 21.4.2009 - WPTools 6.03.1 - fix problem with images when used in Delphi 2009 - better support for header/footer in RTF files created by word. (Ignore bogus header/footer) - soome stability fixes 25.3.2009 - WPTools 6.03 + improved text rendering - optimation for character distances on screen to provide better display + improvement on ShowMergeFieldNames to improve cursor movement and drag and drop + automatic disable dragging of fields inside of fields + improved merge field selection. TextObject.SelectedObject now returns the mergefield if it was completely selected + change in HTML saving code to save src in after width adn height (for outlook) * various bugfixes 17.1.2009 - WPTools 6.02 - WPPREMIUM: Text after Columns initialized with WPAT_COLUMNS_Y is now allowed + TWPToolBar FontName drop down now lists fonts used by document first - fix for tables which use a fixed row height and are splitted on different pages + improvements necessary for Delphi 2009 - the Locaization demo now works + EditOptionEx wpDontPreserveObjectsAgainstDeletion - fix problem in ImageObject LoadFromStream when GraphicEx is used - fix problem with Delphi 2009 when loading WPReporter templates - fix problem with HTML reader with paragraph style of first paragraph + GetFontUnicodeRanges dynamically linked to avoid Win98 problem 26.10.2008 - WPTools 6.01 * updated HTTP Demo, now with "Source View" + DELETE/BACKSPC at start of line removes right/center alignment + loads background images for paragraphs, tables and styles * improvement to text protection (empty lines) - improvements to HTML and CSS reader - improved HTML format routine - improved MIME loading - now supports binary data despite Synapse does not) + MIME reader capturesHTML body for SourceVIew * DataProvider now uses MergeText('',true) instead of MergeText + boolean wphttp_Disable to disconnect HTTP temporarily * several changes to improve compatibility with Delphi 2009 17.10.2008 - WPTools 6.00.1 - several changes to fix problems which occured with use of Delphi 2009 * update to WPIO_MIME to also load binary encoded GIFS and JPEGS from EML files 16.10.2008 - WPTools 6.00 * new installer + VCL demo * fixed problem with TWPComboBox and default attributes * updated "Tasks\Mini" demo project - fix in default actions 3.10.2008 - WPTools 6 Beta c - remove not required unit reference form WPRTEReport * update to manual 2.10.2008 - WPTools 6 Beta b - fix in Installation script 30.9.2008 - WPTools 6 Beta a 1) Application-Server-Mode WPTools 6 introduces a feature which is called "Application-Server-Mode". This is only available when you have the PREMIUM version. This mode is activated when true is assigned to the global boolean variable WPAppServerMode. When this mode is activated the editor does not use the double buffered output anymore. While this can cause some flickering the network traffic is reduced when the application runs on an application server, such as Citrix. Please note, effective with WPTools 6, software which was written for application servers (such as clinic software) may only be distributed when a TEAM or SITE license of WPTools was acquired.END 2) Integrated Label Printing When activated the integrated label printing shows multiple labels on one virtual sheet of paper. The cursor can move from label to label freely. The user can so edit the labels, add new or delete unwanted labels before the complete sheet is printed. This is a very unique and versatile feature. 3) Additions to the PDF export with wPDF V3 Create embedded data objects Create edit / memo fields Create a check box field Also the creation of PDF tags was enhanced. So now hints to paragraph styles will be also exported. 4) Additional Control over Clipboard Actions a) properties to select the format b) added security 5) Added Section API + WPRichText1.ActiveSection + WPRichText1.InputSection + TWPPagePropDlg has new method ExecuteEx. Use it to change current page size or Section WPPagePropDlg1.ExecuteEx(WPRichText1.ActiveSection); 6) Load over HTTP connections (requires Synapse) 7) Load and save MIME encoded HTML with embedded images (requires Synapse) 8) Integrated XML syntax highlighting (non destructive) 9) WPReporter: Token to Template conversion with syntax highlighting 10) Additions to paragraph API 11) Special mode to format HTML documents
jQuery详细教程,讲解很透彻, 一. jQuery 语法实例 $(this).hide() 演示 jQuery hide() 函数,隐藏当前的 HTML 元素。 $("#test").hide() 演示 jQuery hide() 函数,隐藏 id="test" 的元素。 $("p").hide() 演示 jQuery hide() 函数,隐藏所有 元素。 $(".test").hide() 演示 jQuery hide() 函数,隐藏所有 class="test" 的元素。 jQuery 语法 jQuery 语法是为 HTML 元素的选取编制的,可以对元素执行某些操作。 基础语法是:$(selector).action() • 美元符号定义 jQuery • 选择符(selector)“查询”和“查找” HTML 元素 • jQuery 的 action() 执行对元素的操作 示例 $(this).hide() - 隐藏当前元素 $("p").hide() - 隐藏所有段落 $("p.test").hide() - 隐藏所有 class="test" 的段落 $("#test").hide() - 隐藏所有 id="test" 的元素 提示:jQuery 使用的语法是 XPath 与 CSS 选择器语法的组合。在本教程接下来的章节,您将学习到更多有关选择器的语法。 文档就绪函数 您也许已经注意到在我们的实例中的所有 jQuery 函数位于一个 document ready 函数中: $(document).ready(function(){ --- jQuery functions go here ---- }); 这是为了防止文档在完全加载(就绪)之前运行 jQuery 代码。 二. jQuery 选择器 在前面的章节中,我们展示了一些有关如何选取 HTML 元素的实例。 关键点是学习 jQuery 选择器是如何准确地选取您希望应用效果的元素。 jQuery 元素选择器和属性选择器允许您通过标签名、属性名或内容对 HTML 元素进行选择。 选择器允许您对 HTML 元素组或单个元素进行操作。 在 HTML DOM 术语中: 选择器允许您对 DOM 元素组或单个 DOM 节点进行操作。 jQuery 元素选择器 jQuery 使用 CSS 选择器来选取 HTML 元素。 $("p") 选取 元素。 $("p.intro") 选取所有 class="intro" 的 元素。 $("p#demo") 选取 id="demo" 的第一个 元素。 jQuery 属性选择器 jQuery 使用 XPath 表达式来选择带有给定属性的元素。 $("[href]") 选取所有带有 href 属性的元素。 $("[href='#']") 选取所有带有 href 值等于 "#" 的元素。 $("[href!='#']") 选取所有带有 href 值不等于 "#" 的元素。 $("[href$='.jpg']") 选取所有 href 值以 ".jpg" 结尾的元素。 jQuery CSS 选择器 jQuery CSS 选择器可用于改变 HTML 元素的 CSS 属性。 下面的例子把所有 p 元素的背景颜色更改为红色: 实例 $("p").css("background-color","red"); 更多的选择器实例 语法 描述 $(this) 当前 HTML 元素 $("p") 所有 元素 $("p.intro") 所有 class="intro" 的 元素 $(".intro") 所有 class="intro" 的元素 $("#intro") id="intro" 的第一个元素 $("ul li:first") 每个 的第一个 元素 $("[href$='.jpg']") 所有带有以 ".jpg" 结尾的属性值的 href 属性 $("div#intro .head") id="intro" 的 元素中的所有 class="head" 的元素 三. jQuery 事件函数 jQuery 事件处理方法是 jQuery 中的核心函数。 事件处理程序指的是当 HTML 中发生某些事件时所调用的方法。术语由事件“触发”(或“激发”)经常会被使用。 通常会把 jQuery 代码放到 部分的事件处理方法中: 实例 $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); This is a heading This is a paragraph. This is another paragraph. Click me 亲自试一试 在上面的例子中,当按钮的点击事件被触发时会调用一个函数: $("button").click(function() {..some code... } ) 该方法隐藏所有 元素: $("p").hide(); 单独文件中的函数 如果您的网站包含许多页面,并且您希望您的 jQuery 函数易于维护,那么请把您的 jQuery 函数放到独立的 .js 文件中。 当我们在教程中演示 jQuery 时,会将函数直接添加到 部分中。不过,把它们放到一个单独的文件中会更好,就像这样(通过 src 属性来引用文件): 实例 jQuery 名称冲突 jQuery 使用 $ 符号作为 jQuery 的简介方式。 某些其他 JavaScript 库中的函数(比如 Prototype)同样使用 $ 符号。 jQuery 使用名为 noConflict() 的方法来解决该问题。 var jq=jQuery.noConflict(),帮助您使用自己的名称(比如 jq)来代替 $ 符号。 亲自试一试 结论 由于 jQuery 是为处理 HTML 事件而特别设计的,那么当您遵循以下原则时,您的代码会更恰当且更易维护: • 把所有 jQuery 代码置于事件处理函数中 • 把所有事件处理函数置于文档就绪事件处理器中 • 把 jQuery 代码置于单独的 .js 文件中 • 如果存在名称冲突,则重命名 jQuery 库 jQuery 事件 下面是 jQuery 中事件方法的一些例子: Event 函数 绑定函数至 $(document).ready(function) 将函数绑定到文档的就绪事件(当文档完成加载时) $(selector).click(function) 触发或将函数绑定到被选元素的点击事件 $(selector).dblclick(function) 触发或将函数绑定到被选元素的双击事件 $(selector).focus(function) 触发或将函数绑定到被选元素的获得焦点事件 $(selector).mouseover(function) 触发或将函数绑定到被选元素的鼠标悬停事件 四. jQuery实例 jQuery hide() 演示简单的 jQuery hide() 函数。 $(document).ready(function(){ $("p").click(function(){ $(this).hide(); }); }); If you click on me, I will disappear. jQuery hide() 另一个 hide() 演示。如何隐藏部分文本。 $(document).ready(function(){ $(".ex .hide").click(function(){ $(this).parents(".ex").hide("slow"); }); }); div.ex { background-color:#e5eecc; padding:7px; border:solid 1px #c3c3c3; } Island Trading Hide me Contact: Helen Bennett Garden House Crowther Way London Paris Trading Hide me Contact: Marie Bertrand 265, Boulevard Charonne Paris jQuery slideToggle() 演示简单的 slide panel 效果 $(document).ready(function(){ $(".flip").click(function(){ $(".panel").slideToggle("slow"); }); }); div.panel,p.flip { margin:0px; padding:5px; text-align:center; background:#e5eecc; border:solid 1px #c3c3c3; } div.panel { height:120px; display:none; } W3School - 领先的 Web 技术教程站点 在 W3School,你可以找到你所需要的所有网站建设教程。 请点击这里 jQuery fadeTo() 演示简单的 jQuery fadeTo() 函数。 $(document).ready(function(){ $("button").click(function(){ $("div").fadeTo("slow",0.25); }); }); 点击这里查看淡出效果 jQuery animate() 演示简单的 jQuery animate() 函数。 $(document).ready(function(){ $("#start").click(function(){ $("#box").animate({height:300},"slow"); $("#box").animate({width:300},"slow"); $("#box").animate({height:100},"slow"); $("#box").animate({width:100},"slow"); }); }); Start Animation jQuery 隐藏和显示 通过 hide() 和 show() 两个函数,jQuery 支持对 HTML 元素的隐藏和显示: 实例 $("#hide").click(function(){ $("p").hide(); }); $("#show").click(function(){ $("p").show(); }); 亲自试一试 $(document).ready(function(){ $("#hide").click(function(){ $("p").hide(); }); $("#show").click(function(){ $("p").show(); }); }); 如果点击“隐藏”按钮,我就会消失。 隐藏 显示 hide() 和 show() 都可以设置两个可选参数:speed 和 callback。 语法: $(selector).hide(speed,callback) $(selector).show(speed,callback) speed 参数规定显示或隐藏的速度。可以设置这些值:"slow", "fast", "normal" 或毫秒。 callback 参数是在 hide 或 show 函数完成之后被执行的函数名称。您将在本教程下面的章节学习更多有关 callback 参数的知识。 实例 $("button").click(function(){ $("p").hide(1000); }); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("p").hide(1000); }); }); 隐藏 This is a paragraph with little content. This is another small paragraph. jQuery 切换 jQuery toggle() 函数使用 show() 或 hide() 函数来切换 HTML 元素的可见状态。 隐藏显示的元素,显示隐藏的元素。 语法: $(selector).toggle(speed,callback) speed 参数可以设置这些值:"slow", "fast", "normal" 或 毫秒。 实例 $("button").click(function(){ $("p").toggle(); }); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("p").toggle(); }); }); 切换 This is a paragraph with little content. This is another small paragraph. callback 参数是在该函数完成之后被执行的函数名称。您将在本教程下面的章节学习更多有关 callback 参数的知识。 jQuery 滑动函数 - slideDown, slideUp, slideToggle jQuery 拥有以下滑动函数: $(selector).slideDown(speed,callback) $(selector).slideUp(speed,callback) $(selector).slideToggle(speed,callback) speed 参数可以设置这些值:"slow", "fast", "normal" 或毫秒。 callback 参数是在该函数完成之后被执行的函数名称。您将在本教程下面的章节学习更多有关 callback 参数的知识。 slideDown() 实例 $(".flip").click(function(){ $(".panel").slideDown(); }); 亲自试一试 $(document).ready(function(){ $(".flip").click(function(){ $(".panel").slideDown("slow"); }); }); div.panel,p.flip { margin:0px; padding:5px; text-align:center; background:#e5eecc; border:solid 1px #c3c3c3; } div.panel { height:120px; display:none; } W3School - 领先的 Web 技术教程站点 在 W3School,你可以找到你所需要的所有网站建设教程。 请点击这里 slideUp() 实例 $(".flip").click(function(){ $(".panel").slideUp() }) 亲自试一试 $(document).ready(function(){ $(".flip").click(function(){ $(".panel").slideUp("slow"); }); }); div.panel,p.flip { margin:0px; padding:5px; text-align:center; background:#e5eecc; border:solid 1px #c3c3c3; } div.panel { height:120px; } W3School - 领先的 Web 技术教程站点 在 W3School,你可以找到你所需要的所有网站建设教程。 请点击这里 slideToggle() 实例 $(".flip").click(function(){ $(".panel").slideToggle(); }); 亲自试一试 $(document).ready(function(){ $(".flip").click(function(){ $(".panel").slideToggle("slow"); }); }); div.panel,p.flip { margin:0px; padding:5px; text-align:center; background:#e5eecc; border:solid 1px #c3c3c3; } div.panel { height:120px; display:none; } W3School - 领先的 Web 技术教程站点 在 W3School,你可以找到你所需要的所有网站建设教程。 请点击这里 jQuery Fade 函数 - fadeIn(), fadeOut(), fadeTo() jQuery 拥有以下 fade 函数: $(selector).fadeIn(speed,callback) $(selector).fadeOut(speed,callback) $(selector).fadeTo(speed,opacity,callback) speed 参数可以设置这些值:"slow", "fast", "normal" 或 毫秒。 fadeTo() 函数中的 opacity 参数规定减弱到给定的不透明度。 callback 参数是在该函数完成之后被执行的函数名称。您将在本教程下面的章节学习更多有关 callback 参数的知识。 fadeTo() 实例 $("button").click(function(){ $("div").fadeTo("slow",0.25); }); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("div").fadeTo("slow",0.25); }); }); 点击这里查看淡出效果 fadeOut() 实例 $("button").click(function(){ $("div").fadeOut(4000); }); 亲自试一试 $(document).ready(function(){ $("#test").click(function(){ $(this).fadeOut(4000); }); }); CLICK ME AWAY! 如果您点击上面的框,它会淡出直到消失为止。 jQuery 自定义动画 jQuery 函数创建自定义动画的语法: $(selector).animate({params},[duration],[easing],[callback]) 关键的参数是 params。它定义产生动画的 CSS 属性。可以同时设置多个此类属性: animate({width:"70%",opacity:0.4,marginLeft:"0.6in",fontSize:"3em"}); 第二个参数是 duration。它定义用来应用到动画的时间。它设置的值是:"slow", "fast", "normal" 或毫秒。 实例 1 $(document).ready(function(){ $("#start").click(function(){ $("#box").animate({height:300},"slow"); $("#box").animate({width:300},"slow"); $("#box").animate({height:100},"slow"); $("#box").animate({width:100},"slow"); }); }); 亲自试一试 $(document).ready(function(){ $("#start").click(function(){ $("#box").animate({height:300},"slow"); $("#box").animate({width:300},"slow"); $("#box").animate({height:100},"slow"); $("#box").animate({width:100},"slow"); }); }); Start Animation 实例 2 $(document).ready(function(){ $("#start").click(function(){ $("#box").animate({left:"100px"},"slow"); $("#box").animate({fontSize:"3em"},"slow"); }); }); 亲自试一试 $(document).ready(function(){ $("#start").click(function(){ $("#box").animate({left:"100px"},"slow"); $("#box").animate({fontSize:"3em"},"slow"); }); }); Start Animation HELLO HTML 元素默认是静态定位,且无法移动。 如需使元素可以移动,请把 CSS 的 position 设置为 relative 或 absolute。 jQuery 效果 - 来自本页 函数 描述 $(selector).hide() 隐藏被选元素 $(selector).show() 显示被选元素 $(selector).toggle() 切换(在隐藏与显示之间)被选元素 $(selector).slideDown() 向下滑动(显示)被选元素 $(selector).slideUp() 向上滑动(隐藏)被选元素 $(selector).slideToggle() 对被选元素切换向上滑动和向下滑动 $(selector).fadeIn() 淡入被选元素 $(selector).fadeOut() 淡出被选元素 $(selector).fadeTo() 把被选元素淡出为给定的不透明度 $(selector).animate() 对被选元素执行自定义动画 五. JQuery Callback 函数 jQuery 动画的问题 许多 jQuery 函数涉及动画。这些函数也许会将 speed 或 duration 作为可选参数。 例子:$("p").hide("slow") speed 或 duration 参数可以设置许多不同的值,比如 "slow", "fast", "normal" 或毫秒。 实例 $("button").click(function(){ $("p").hide(1000); }); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("p").hide(1000); }); }); 隐藏 This is a paragraph with little content. This is another small paragraph. 由于 JavaScript 语句(指令)是逐一执行的 - 按照次序,动画之后的语句可能会产生错误或页面冲突,因为动画还没有完成。 为了避免这个情况,您可以以参数的形式添加 Callback 函数。 jQuery Callback 函数 当动画 100% 完成后,即调用 Callback 函数。 典型的语法: $(selector).hide(speed,callback) callback 参数是一个在 hide 操作完成后被执行的函数。 错误(没有 callback) $("p").hide(1000); alert("The paragraph is now hidden"); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("p").hide(2000); alert("The paragraph is now hidden"); }); }); Hide This is a paragraph with little content. 正确(有 callback) $("p").hide(1000,function(){ alert("The paragraph is now hidden"); }); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("p").hide(1000,function(){ alert("The paragraph is now hidden"); }); }); }); Hide This is a paragraph with little content. 六. jQuery 包含很多供改变和操作 HTML 的强大函数。 改变 HTML 内容 语法 $(selector).html(content) html() 函数改变所匹配的 HTML 元素的内容(innerHTML)。 实例 $("p").html("W3School"); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("p").html("W3School"); }); }); This is a heading This is a paragraph. This is another paragraph. 请点击这里 添加 HTML 内容 语法 $(selector).append(content) append() 函数向所匹配的 HTML 元素内部追加内容。 语法 $(selector).prepend(content) prepend() 函数向所匹配的 HTML 元素内部预置(Prepend)内容。 实例 $("p").append(" W3School"); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("p").append(" W3School."); }); }); This is a heading This is a paragraph. This is another paragraph. 请点击这里 语法 $(selector).after(content) after() 函数在所有匹配的元素之后插入 HTML 内容。 语法 $(selector).before(content) before() 函数在所有匹配的元素之前插入 HTML 内容。 实例 $("p").after(" W3School."); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("p").after(" W3School."); }); }); This is a heading This is a paragraph. This is another paragraph. 请点击这里 jQuery HTML 操作 - 来自本页 函数 描述 $(selector).html(content) 改变被选元素的(内部)HTML $(selector).append(content) 向被选元素的(内部)HTML 追加内容 $(selector).prepend(content) 向被选元素的(内部)HTML “预置”(Prepend)内容 $(selector).after(content) 在被选元素之后添加 HTML $(selector).before(content) 在被选元素之前添加 HTML 七. jQuery CSS 操作 jQuery 拥有三种用于 CSS 操作的重要函数: • $(selector).css(name,value) • $(selector).css({properties}) • $(selector).css(name) CSS 操作实例 函数 css(name,value) 为所有匹配元素的给定 CSS 属性设置值: 实例 $(selector).css(name,value) $("p").css("background-color","red"); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("p").css("background-color","red"); }); }); This is a heading This is a paragraph. This is another paragraph. Click me 函数 css({properties}) 同时为所有匹配元素的一系列 CSS 属性设置值: 实例 $(selector).css({properties}) $("p").css({"background-color":"red","font-size":"200%"}); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("p").css({"background-color":"red","font-size":"200%"}); }); }); This is a heading This is a paragraph. This is another paragraph. Click me 函数 css(name) 返回指定的 CSS 属性的值: 实例 $(selector).css(name) $(this).css("background-color"); 亲自试一试 $(document).ready(function(){ $("div").click(function(){ $("#result").html($(this).css("background-color")); }); }); Click in the box jQuery Size 操作 jQuery 拥有两种用于尺寸操作的重要函数: • $(selector).height(value) • $(selector).width(value) Size 操作实例 函数 height(value) 设置所有匹配元素的高度: 实例 $(selector).height(value) $("#id100").height("200px"); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("#id100").height("200px"); }); }); HELLO W3SCHOOL 请点击这里 函数 width(value) 设置所有匹配元素的宽度: 实例 $(selector).width(value) $("#id200").width("300px"); 亲自试一试 $(document).ready(function(){ $("button").click(function(){ $("#id200").width("300px"); }); }); HELLO W3SCHOOL 请点击这里 jQuery CSS 函数 - 来自本页 CSS 属性 描述 $(selector).css(name,value) 为匹配元素设置样式属性的值 $(selector).css({properties}) 为匹配元素设置多个样式属性 $(selector).css(name) 获得第一个匹配元素的样式属性值 $(selector).height(value) 设置匹配元素的高度 $(selector).width(value) 设置匹配元素的宽度 八. jQuery 参考手册 @ jQuery 选择器 选择器 实例 选取 * $("*") 所有元素 #id $("#lastname") id="lastname" 的元素 .class $(".intro") 所有 class="intro" 的元素 element $("p") 所有 元素 .class.class $(".intro.demo") 所有 class="intro" 且 class="demo" 的元素 :first $("p:first") 第一个 元素 :last $("p:last") 最后一个 元素 :even $("tr:even") 所有偶数 元素 :odd $("tr:odd") 所有奇数 元素 :eq(index) $("ul li:eq(3)") 列表中的第四个元素(index 从 0 开始) :gt(no) $("ul li:gt(3)") 列出 index 大于 3 的元素 :lt(no) $("ul li:lt(3)") 列出 index 小于 3 的元素 :not(selector) $("input:not(:empty)") 所有不为空的 input 元素 :header $(":header") 所有标题元素 - :animated 所有动画元素 :contains(text) $(":contains('W3School')") 包含指定字符串的所有元素 :empty $(":empty") 无子(元素)节点的所有元素 :hidden $("p:hidden") 所有隐藏的 元素 :visible $("table:visible") 所有可见的表格 s1,s2,s3 $("th,td,.intro") 所有带有匹配选择的元素 [attribute] $("[href]") 所有带有 href 属性的元素 [attribute=value] $("[href='#']") 所有 href 属性的值等于 "#" 的元素 [attribute!=value] $("[href!='#']") 所有 href 属性的值不等于 "#" 的元素 [attribute$=value] $("[href$='.jpg']") 所有 href 属性的值包含 ".jpg" 的元素 :input $(":input") 所有 元素 :text $(":text") 所有 type="text" 的 元素 :password $(":password") 所有 type="password" 的 元素 :radio $(":radio") 所有 type="radio" 的 元素 :checkbox $(":checkbox") 所有 type="checkbox" 的 元素 :submit $(":submit") 所有 type="submit" 的 元素 :reset $(":reset") 所有 type="reset" 的 元素 :button $(":button") 所有 type="button" 的 元素 :image $(":image") 所有 type="image" 的 元素 :file $(":file") 所有 type="file" 的 元素 :enabled $(":enabled") 所有激活的 input 元素 :disabled $(":disabled") 所有禁用的 input 元素 :selected $(":selected") 所有被选取的 input 元素 :checked $(":checked") 所有被选中的 input 元素 @ jQuery 事件方法 事件方法会触发匹配元素的事件,或将函数绑定到所有匹配元素的某个事件。 触发实例: $("button#demo").click() 上面的例子将触发 id="demo" 的 button 元素的 click 事件。 绑定实例: $("button#demo").click(function(){$("img").hide()}) 上面的例子会在点击 id="demo" 的按钮时隐藏所有图像。 方法 描述 bind() 向匹配元素附加一个或更多事件处理器 blur() 触发、或将函数绑定到指定元素的 blur 事件 change() 触发、或将函数绑定到指定元素的 change 事件 click() 触发、或将函数绑定到指定元素的 click 事件 dblclick() 触发、或将函数绑定到指定元素的 double click 事件 delegate() 向匹配元素的当前或未来的子元素附加一个或多个事件处理器 die() 移除所有通过 live() 函数添加的事件处理程序。 error() 触发、或将函数绑定到指定元素的 error 事件 event.isDefaultPrevented() 返回 event 对象上是否调用了 event.preventDefault()。 event.pageX 相对于文档左边缘的鼠标位置。 event.pageY 相对于文档上边缘的鼠标位置。 event.preventDefault() 阻止事件的默认动作。 event.result 包含由被指定事件触发的事件处理器返回的最后一个值。 event.target 触发事件的 DOM 元素。 event.timeStamp 该属性返回从 1970 年 1 月 1 日到事件发生时的毫秒数。 event.type 描述事件的类型。 event.which 指示按了哪个键或按钮。 focus() 触发、或将函数绑定到指定元素的 focus 事件 keydown() 触发、或将函数绑定到指定元素的 key down 事件 keypress() 触发、或将函数绑定到指定元素的 key press 事件 keyup() 触发、或将函数绑定到指定元素的 key up 事件 live() 触发、或将函数绑定到指定元素的 load 事件 load() 触发、或将函数绑定到指定元素的 load 事件 mousedown() 触发、或将函数绑定到指定元素的 mouse down 事件 mouseenter() 触发、或将函数绑定到指定元素的 mouse enter 事件 mouseleave() 触发、或将函数绑定到指定元素的 mouse leave 事件 mousemove() 触发、或将函数绑定到指定元素的 mouse move 事件 mouseout() 触发、或将函数绑定到指定元素的 mouse out 事件 mouseover() 触发、或将函数绑定到指定元素的 mouse over 事件 mouseup() 触发、或将函数绑定到指定元素的 mouse up 事件 one() 向匹配元素添加事件处理器。每个元素只能触发一次该处理器。 ready() 文档就绪事件(当 HTML 文档就绪可用时) resize() 触发、或将函数绑定到指定元素的 resize 事件 scroll() 触发、或将函数绑定到指定元素的 scroll 事件 select() 触发、或将函数绑定到指定元素的 select 事件 submit() 触发、或将函数绑定到指定元素的 submit 事件 toggle() 绑定两个或多个事件处理器函数,当发生轮流的 click 事件时执行。 trigger() 所有匹配元素的指定事件 triggerHandler() 第一个被匹配元素的指定事件 unbind() 从匹配元素移除一个被添加的事件处理器 undelegate() 从匹配元素移除一个被添加的事件处理器,现在或将来 unload() 触发、或将函数绑定到指定元素的 unload 事件 @ jQuery 效果函数 方法 描述 animate() 对被选元素应用“自定义”的动画 clearQueue() 对被选元素移除所有排队的函数(仍未运行的) delay() 对被选元素的所有排队函数(仍未运行)设置延迟 dequeue() 运行被选元素的下一个排队函数 fadeIn() 淡入被选元素至完全不透明 fadeOut() 淡出被选元素至完全不透明 fadeTo() 把被选元素减弱至给定的不透明度 hide() 隐藏被选的元素 queue() 显示被选元素的排队函数 show() 显示被选的元素 slideDown() 通过调整高度来滑动显示被选元素 slideToggle() 对被选元素进行滑动隐藏和滑动显示的切换 slideUp() 通过调整高度来滑动隐藏被选元素 stop() 停止在被选元素上运行动画 toggle() 对被选元素进行隐藏和显示的切换 @ jQuery 文档操作方法 这些方法对于 XML 文档和 HTML 文档均是适用的,除了:html()。 方法 描述 addClass() 向匹配的元素添加指定的类名。 after() 在匹配的元素之后插入内容。 append() 向匹配的元素内部追加内容。 appendTo() 向匹配的元素内部追加内容。 attr() 设置或返回匹配元素的属性和值。 before() 在每个匹配的元素之前插入内容。 clone() 创建匹配元素集合的副本。 detach() 从 DOM 中移除匹配元素集合。 empty() 删除匹配的元素集合中所有的子节点。 hasClass() 检查匹配的元素是否拥有指定的类。 html() 设置或返回匹配的元素集合中的 HTML 内容。 insertAfter() 把匹配的元素插入到另一个指定的元素集合的后面。 insertBefore() 把匹配的元素插入到另一个指定的元素集合的前面。 prepend() 向每个匹配的元素内部前置内容。 prependTo() 向每个匹配的元素内部前置内容。 remove() 移除所有匹配的元素。 removeAttr() 从所有匹配的元素中移除指定的属性。 removeClass() 从所有匹配的元素中删除全部或者指定的类。 replaceAll() 用匹配的元素替换所有匹配到的元素。 replaceWith() 用新内容替换匹配的元素。 text() 设置或返回匹配元素的内容。 toggleClass() 从匹配的元素中添加或删除一个类。 unwrap() 移除并替换指定元素的父元素。 val() 设置或返回匹配元素的值。 wrap() 把匹配的元素用指定的内容或元素包裹起来。 wrapAll() 把所有匹配的元素用指定的内容或元素包裹起来。 wrapinner() 将每一个匹配的元素的子内容用指定的内容或元素包裹起来。 @ jQuery 属性操作方法 下面列出的这些方法获得或设置元素的 DOM 属性。 这些方法对于 XML 文档和 HTML 文档均是适用的,除了:html()。 方法 描述 addClass() 向匹配的元素添加指定的类名。 attr() 设置或返回匹配元素的属性和值。 hasClass() 检查匹配的元素是否拥有指定的类。 html() 设置或返回匹配的元素集合中的 HTML 内容。 removeAttr() 从所有匹配的元素中移除指定的属性。 removeClass() 从所有匹配的元素中删除全部或者指定的类。 toggleClass() 从匹配的元素中添加或删除一个类。 val() 设置或返回匹配元素的值。 @ jQuery CSS 操作函数 下面列出的这些方法设置或返回元素的 CSS 相关属性。 CSS 属性 描述 css() 设置或返回匹配元素的样式属性。 height() 设置或返回匹配元素的高度。 offset() 返回第一个匹配元素相对于文档的位置。 offsetParent() 返回最近的定位祖先元素。 position() 返回第一个匹配元素相对于父元素的位置。 scrollLeft() 设置或返回匹配元素相对滚动条顶部的偏移。 scrollTop() 设置或返回匹配元素相对滚动条左侧的偏移。 width() 设置或返回匹配元素的宽度。 @jQuery Ajax 操作函数 jQuery 库拥有完整的 Ajax 兼容套件。其中的函数和方法允许我们在不刷新浏览器的情况下从服务器加载数据。 函数 描述 jQuery.ajax() 执行异步 HTTP (Ajax) 请求。 .ajaxComplete() 当 Ajax 请求完成时注册要调用的处理程序。这是一个 Ajax 事件。 .ajaxError() 当 Ajax 请求完成且出现错误时注册要调用的处理程序。这是一个 Ajax 事件。 .ajaxSend() 在 Ajax 请求发送之前显示一条消息。 jQuery.ajaxSetup() 设置将来的 Ajax 请求的默认值。 .ajaxStart() 当首个 Ajax 请求完成开始时注册要调用的处理程序。这是一个 Ajax 事件。 .ajaxStop() 当所有 Ajax 请求完成时注册要调用的处理程序。这是一个 Ajax 事件。 .ajaxSuccess() 当 Ajax 请求成功完成时显示一条消息。 jQuery.get() 使用 HTTP GET 请求从服务器加载数据。 jQuery.getJSON() 使用 HTTP GET 请求从服务器加载 JSON 编码数据。 jQuery.getScript() 使用 HTTP GET 请求从服务器加载 JavaScript 文件,然后执行该文件。 .load() 从服务器加载数据,然后把返回到 HTML 放入匹配元素。 jQuery.param() 创建数组或对象的序列化表示,适合在 URL 查询字符串或 Ajax 请求中使用。 jQuery.post() 使用 HTTP POST 请求从服务器加载数据。 .serialize() 将表单内容序列化为字符串。 .serializeArray() 序列化表单元素,返回 JSON 数据结构数据。 @ jQuery 遍历函数 jQuery 遍历函数包括了用于筛选、查找和串联元素的方法。 函数 描述 .add() 将元素添加到匹配元素的集合中。 .andSelf() 把堆栈中之前的元素集添加到当前集合中。 .children() 获得匹配元素集合中每个元素的所有子元素。 .closest() 从元素本身开始,逐级向上级元素匹配,并返回最先匹配的祖先元素。 .contents() 获得匹配元素集合中每个元素的子元素,包括文本和注释节点。 .each() 对 jQuery 对象进行迭代,为每个匹配元素执行函数。 .end() 结束当前链中最近的一次筛选操作,并将匹配元素集合返回到前一次的状态。 .eq() 将匹配元素集合缩减为位于指定索引的新元素。 .filter() 将匹配元素集合缩减为匹配选择器或匹配函数返回值的新元素。 .find() 获得当前匹配元素集合中每个元素的后代,由选择器进行筛选。 .first() 将匹配元素集合缩减为集合中的第一个元素。 .has() 将匹配元素集合缩减为包含特定元素的后代的集合。 .is() 根据选择器检查当前的匹配元素集合,如果存在至少一个匹配元素,则返回 true。 .last() 将匹配元素集合缩减为集合中的最后一个元素。 .map() 把当前匹配集合中的每个元素传递给一个函数,产生包含返回值的新的 jQuery 对象。 .next() 获得匹配元素集合中每个元素紧邻的同辈元素。 .nextAll() 获得匹配元素集合中每个元素之后的所有同辈元素,由选择器进行筛选(可选)。 .nextUntil() 获得每个元素之后所有的同辈元素,直到遇到匹配选择器的元素为止。 .not() 从匹配元素集合中删除元素。 .offsetParent() 获得用于定位的第一个父元素。 .parent() 获得当前匹配元素集合中每个元素的父元素,由选择器筛选(可选)。 .parentsUntil() 获得当前匹配元素集合中每个元素的祖先元素,直到遇到匹配选择器的元素为止。 .prev() 获得匹配元素集合中每个元素紧邻的前一个同辈元素,由选择器筛选(可选)。 .prevAll() 获得匹配元素集合中每个元素之前的所有同辈元素,由选择器进行筛选(可选)。 .prevUntil() 获得每个元素之前所有的同辈元素,直到遇到匹配选择器的元素为止。 .siblings() 获得匹配元素集合中所有元素的同辈元素,由选择器筛选(可选)。 .slice() 将匹配元素集合缩减为指定范围的子集。 @ jQuery 数据存储函数 这些方法允许我们将指定的 DOM 元素与任意数据相关联。 函数 描述 .data() 存储与匹配元素相关的任意数据。 jQuery.data() 存储与指定元素相关的任意数据。 .removeData() 移除之前存放的数据。 jQuery.removeData() 移除之前存放的数据。 @ jQuery 队列控制函数 函数 描述 .clearQueue() 从队列中删除所有未运行的项目。 .dequeue() 从队列最前端移除一个队列函数,并执行它。 jQuery.dequeue() 从队列最前端移除一个队列函数,并执行它。 .queue() 显示或操作匹配元素所执行函数的队列。 jQuery.queue() 显示或操作匹配元素所执行函数的队列。 九. jQuery 核心函数 函数 描述 jQuery() 接受一个字符串,其中包含了用于匹配元素集合的 CSS 选择器。 实例 找出所有属于 div 元素的子元素的 p 元素,然后设置其边框属性: $("div > p").css("border", "1px solid gray"); 亲自试一试 定义和用法 jQuery() 方法接受一个字符串,其中包含了用于匹配元素集合的 CSS 选择器。 jQuery() 函数有三种语法: 语法 1 接受一个字符串,其中包含了用于匹配元素集合的 CSS 选择器: jQuery(selector, [context]) 详细用法 语法 2 使用原始 HTML 的字符串来创建 DOM 元素: jQuery(html,[ownerDocument]) 详细用法 语法 3 绑定一个在 DOM 文档载入完成后执行的函数: jQuery( callback ) 详细用法 jQuery( selector, [ context ] ) 该语法有以下几种用法: 用法 1 :设置选择器环境 语法 jQuery(selector, [context]) 默认情况下,选择器从文档根部对 DOM 进行搜索。不过,可以为 $() 设置可选的 context 参数。 例如,如果我们希望在一个 callback 中搜索一个元素,可以限定下面的搜索: 实例 $("div.foo").click(function() { $("span", this).addClass("bar"); }); 由于我们已经将 span 选择器限定到 this 这个环境中,只有被点击元素中的 span 会得到附加的 class。 在内部,选择器环境是通过 .find() 方法实现的,因此 $("span", this) 等价于 $(this).find("span")。 jQuery 的核心功能都是通过这个函数实现的。jQuery中的一切都基于这个函数,或者说都是在以某种方式使用这个函数。这个函数最基本的用法就是向它传递一个表达式(通常由 CSS 选择器组成),然后根据这个表达式来查找所有匹配的元素。 默认情况下, 如果没有指定 context 参数,$() 将在当前的 HTML document 中查找 DOM 元素;如果指定了 context 参数,如一个 DOM 元素集或 jQuery 对象,那就会在这个 context 中查找。在 jQuery 1.3.2 以后,其返回的元素顺序等同于在 context 中出现的先后顺序。 用法 2 :使用 DOM 元素 语法 jQuery(element) 该函数允许我们通过使用以其他方式找到的 DOM 元素来创建 jQuery 对象。该功能通常的用法是,对已经通过 this 关键字传递到 callback 函数的元素调用 jQuery 的方法: 实例 $("div.foo").click(function() { $(this).slideUp(); }); 此例会在元素被点击时使用滑动动画对其进行隐藏。由于处理程序接受的 this 关键词中的被点击项目是纯的 DOM 元素,因此在对其调用 jQuery 的方法之前,必须用 jQuery 对象包装该元素。 这个函数也可以接收 XML 文档和 Window 对象(虽然它们不是 DOM 元素)作为有效的参数。 当 XML 数据从 Ajax 调用中返回后,我们可以使用 $() 函数通过 jQuery 对象包装该数据。一旦完成,我们就可以使用 .find() 和其他 DOM 遍历方法来取回 XML 结构中单个元素。 用法 3 :克隆 jQuery 对象 语法 jQuery(jQuery object) 当以参数的形式向 $() 函数传递 jQuery 对象后,会创建一个该对象的副本。与初始对象一样,新的 jQuery 对象引用相同的 DOM 元素。 用法 4 :返回空的集合 语法 jQuery() 对于 jQuery 1.4,调用无参数的 jQuery() 方法会返回空的 jQuery 集合。在之前版本的 jQuery 中,这样会返回包含 document 节点的集合。 jQuery( html, [ ownerDocument ] ) 该语法有以下几种用法: 用法 1 :创建新的元素 语法 jQuery(html,[ownerDocument]) 你可以传递一个手写的 HTML 字符串,或者由某些模板引擎或插件创建的字符串,也可以是通过 AJAX 加载过来的字符串。但是在你创建 input 元素的时会有限制,可以参考第二个示例。 当然这个字符串可以包含斜杠 (比如一个图像地址),还有反斜杠。当你创建单个元素时,请使用闭合标签或 XHTML 格式。例如,创建一个 span ,可以用 $("") 或 $("") ,但不推荐 $("")。在 jQuery 中,这个语法等同于 $(document.createElement("span"))。 如果以参数的形式将字符串传递给 $(),jQuery 会检查字符串是否是 HTML (比如,字符串某些位置存在标签)。如果不是,则把字符串解释为选择器表达式,请见上面的讲解。但如果字符串是 HTML 片段,则 jQuery 试图创建由该 HTML 片段描述的 DOM 元素。然后会创建并返回一个引用这些 DOM 元素的 jQuery 对象: 实例 $("My new text").appendTo("body"); 如果 HTML 片段比不含属性的简单标签更复杂,如同上面例子中的 HTML,那么元素实际的创建过程是由浏览器的 innerHTML 机制完成的。具体地讲,jQuery 会创建新的 元素,然后为传入的 HTML 片段设置元素的 innerHTML 属性。当参数只是简单的标签,比如$("") 或 $(""),jQuery 会通过内生的 JavaScript createElement() 函数来创建元素。 要确保跨平台兼容性,片段的结构必须良好。能够包含其他元素的标签必须成对出现(带有关闭标签): $(""); 不过,jQuery 也允许类似 XML 的标签语法: $(""); 无法包含其他元素的标签可以关闭,也可以不关闭: $(""); $(""); 用法 2 :设置属性和事件 语法 jQuery(html,props) 对于 jQuery 1.4,我们可以向第二个参数传递一个属性映射。该参数接受能够传递给 .attr() 方法的属性的超集。此外,可以传递任意的事件类型,并可以调用下面的 jQuery 方法:val, css, html, text, data, width, height, or offset. 注意,Internet Explorer 不允许你创建 input 元素并改变其类型;您必须使用例如 "" 来规定类型。 实例 创建一个 元素,同时设定 type 属性、属性值,以及一些事件。 $("", { type: "text", val: "Test", focusin: function() { $(this).addClass("active"); }, focusout: function() { $(this).removeClass("active"); } }).appendTo("form"); jQuery( callback ) 允许你绑定一个在 DOM 文档载入完成后执行的函数。 该函数的作用如同 $(document).ready() 一样,只不过用这个函数时,需要把页面中所有需要在 DOM 加载完成时执行的其他 $() 操作符都包装到其中来。尽管从技术上来说,这个函数是可链接的,但真正以这种方式链接的情况并不多。 例子 当DOM加载完成后,执行其中的函数: $(function(){ // 文档就绪 }); 函数 描述 jQuery.noConflict() 运行这个函数将变量 $ 的控制权让渡给第一个实现它的那个库。 定义和用法 noConflict() 方法让渡变量 $ 的 jQuery 控制权。 语法 jQuery.noConflict([removeAll]) 参数 描述 removeAll 布尔值。指示是否允许彻底将 jQuery 变量还原。 说明 许多 JavaScript 库使用 $ 作为函数或变量名,jQuery 也一样。在 jQuery 中,$ 仅仅是 jQuery 的别名,因此即使不使用 $ 也能保证所有功能性。假如我们需要使用 jQuery 之外的另一 JavaScript 库,我们可以通过调用 $.noConflict() 向该库返回控制权: $.noConflict(); // 使用另一个库的 $ 的代码 可以与 .ready() 方法结合起来使用,来为 jQuery 对象起别名,这项技术非常有效: $.noConflict(); jQuery(document).ready(function($) { // 使用 jQuery $ 的代码 }); // 使用其他库的 $ 的代码 此外,通过向该方法传递参数 true,我们可以将 $ 和 jQuery 的控制权都交还给原来的库。用之前请考虑清楚! 这是相对于简单的 noConflict 方法更极端的版本,因为这将完全重新定义 jQuery。这通常用于一种极端的情况,比如你想要将 jQuery 嵌入一个高度冲突的环境。注意:调用此方法后极有可能导致插件失效。 实例 例子 1 将 $ 引用的对象映射回原始的对象: jQuery.noConflict(); jQuery("div p").hide(); // 使用 jQuery $("content").style.display = "none"; // 使用其他库的 $() 例子 2 恢复使用别名 $,然后创建并执行一个函数,在这个函数的作用域中仍然将 $ 作为 jQuery 的别名来使用。在这个函数中,原来的 $ 对象是无效的。这个函数对于大多数不依赖于其他库的插件都十分有效: jQuery.noConflict(); (function($) { $(function() { // 使用 $ 作为 jQuery 别名的代码 }); })(jQuery); ... // 其他用 $ 作为别名的库的代码 例子 3 可以将 jQuery.noConflict() 与简写的 ready 结合,使代码更紧凑: jQuery.noConflict()(function(){ // 使用 jQuery 的代码 }); ... // 其他库使用 $ 做别名的代码 例子 4 创建一个新的别名用以在接下来的库中使用 jQuery 对象: var j = jQuery.noConflict(); j("div p").hide(); // 基于 jQuery 的代码 $("content").style.display = "none"; // 基于其他库的 $() 代码 例子 5 完全将 jQuery 移到一个新的命名空间: var dom = {}; dom.query = jQuery.noConflict(true); 结果: dom.query("div p").hide(); // 新 jQuery 的代码 $("content").style.display = "none"; // 另一个库 $() 的代码 jQuery("div > p").hide(); // 另一个版本 jQuery 的代码

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值