phpQueryPHP 的服务器端 jQuery
phpQuery是一个服务器端jQuery开源项目。它可以让PHP开发人员采用与jQuery相同的语法来处理网页元素。
示例代码:
<?php require('phpQuery/phpQuery.php'); // INITIALIZE IT // phpQuery::newDocumentHTML($markup); // phpQuery::newDocumentXML(); // phpQuery::newDocumentFileXHTML('test.html'); // phpQuery::newDocumentFilePHP('test.php'); // phpQuery::newDocument('test.xml', 'application/rss+xml'); // this one defaults to text/html in utf8 $doc = phpQuery::newDocument('<div/>'); // FILL IT // array syntax works like ->find() here $doc['div']->append('<ul></ul>'); // array set changes inner html $doc['div ul'] = '<li>1</li> <li>2</li> <li>3</li>'; // MANIPULATE IT $li = null; // almost everything can be a chain $doc['ul > li'] ->addClass('my-new-class') ->filter(':last') ->addClass('last-li') // save it anywhere in the chain ->toReference($li); // SELECT DOCUMENT // pq(); is using selected document as default phpQuery::selectDocument($doc); // documents are selected when created or by above method // query all unordered lists in last selected document $ul = pq('ul')->insertAfter('div'); // ITERATE IT // all direct LIs from $ul foreach($ul['> li'] as $li) { // iteration returns PLAIN dom nodes, NOT phpQuery objects $tagName = $li->tagName; $childNodes = $li->childNodes; // so you NEED to wrap it within phpQuery, using pq(); pq($li)->addClass('my-second-new-class'); } // PRINT OUTPUT // 1st way print phpQuery::getDocument($doc->getDocumentID()); // 2nd way print phpQuery::getDocument(pq('div')->getDocumentID()); // 3rd way print pq('div')->getDocument(); // 4th way print $doc->htmlOuter(); // 5th way print $doc; // another... print $doc['ul'];
评论
PhantomJSWebKit 的服务器端 API
PhantomJS是一个服务器端的JavaScriptAPI的WebKit。其支持各种Web标准:DOM处理,CSS选择器,JSON,Canvas,和SVG使用场景:无需浏览器的Web测试页面访问自动
PhantomJSWebKit 的服务器端 API
0
PhantomJSWebKit 的服务器端 API
Phantom JS是一个服务器端的 JavaScript API 的 WebKit。其支持各种We
PhantomJSWebKit 的服务器端 API
0
jQuery Planetarium构建行星的 jQuery 插件
Planetarium 是 jQuery 插件,允许用户在网站上构建交互式的行星和宇宙。在线演示
jQuery Planetarium构建行星的 jQuery 插件
0
Node.js服务器端的 JavaScript 运行环境
Node.js是一个跨平台的JavaScript运行时环境。Node.js使用高效、轻量级的事件驱动、非阻塞I/O模型。Node.js的生态系统是目前最大的开源包管理系统。Node.js是一套用来编写
Node.js服务器端的 JavaScript 运行环境
0
jQuery Planetarium构建行星的 jQuery 插件
Planetarium是jQuery插件,允许用户在网站上构建交互式的行星和宇宙。在线演示
jQuery Planetarium构建行星的 jQuery 插件
0
Raygun4jsRaygun 的 jQuery 插件
Raygun4js是提供调用Raygun.io服务的jQuery插件。Raygun.io为你提供记录应用程序错误的平台。
Raygun4jsRaygun 的 jQuery 插件
0