我正在尝试编写一个"Tweet this"按钮,在Twitter上打开一个带有预生成文本的新窗口.我现在得到的是Twitter上的一个窗口,其中包含我来自哪里的URL.我正在使用JQuery API来执行此操作.我项目的链接是http://codepen.io/haldav/pen/KVpojP.我的代码是:
$(document).ready(function() { random(); function random() { var quotes = ["You must be shapeless, formless, like water. When you pour water in a cup, it becomes the cup. When you pour water in a bottle, it becomes the bottle. When you pour water in a teapot, it becomes the teapot. Water can drip and it can crash. Become like water my friend.", "Defeat is a state of mind; no one is ever defeated until defeat has been accepted as a reality.", "The moment has no yesterday or tomorrow. It is not the result of thought and therefore has no time.", "Real living is living for others.", "Never waste energy on worries or negative thoughts, all problems are brought into existence -drop them.", "A goal is not always meant to be reached. It often serves simply as something to aim at.", "Those who are unaware they are walking in darkness will never seek the light.", "Because one does not want to be disturbed, to be made uncertain, he establishes a pattern of conduct, of thought, a pattern of relationship to man etc. Then he becomes a slave to the pattern and takes the pattern to be the real thing."]; randomQuote = quotes[Math.floor(Math.random() * quotes.length)]; quote = randomQuote.split("randomQuote"); $('.quote').text(quote[0]); } $(".button").on("click", function() { random(); }); });
我的HTML代码是:
The Wisdom of Bruce Lee
Although Bruce Lee died at a considerably young age, he was wise beyond his years. For my random quote machine, I chose to showcase some of his wisdom. For this exercise, I used a little JQuery, Bootstrap, CSS and HTML.
Copyright © David C. Hall 2015
我很难过.有什么建议?谢谢.编辑:我正在打开一个新窗口,但我需要它在文本框中显示随机引用.
1> haldav..:弄清楚了!我所要做的就是添加
$(this).attr("href", 'https://twitter.com/intent/tweet?text=' + randomQuote);到我的JS代码.
推荐阅读
如何解决《Chrome开发者工具连接ID》经验,为你挑选了1个好方法。 ... [详细] 如何解决《Javascript的本机排序方法如何工作?》经验,为你挑选了1个好方法。 ... [详细] 如何解决《WordPress的.获取没有特色图片的帖子》经验,为你挑选了1个好方法。 ... [详细] 如何解决《Elasticsearch2.1:如何使用curl通过查询删除》经验,为你挑选了1个好方法。 ... [详细] 如何解决《TouchID-如何进入密码屏幕?-迅速》经验,为你挑选了1个好方法。 ... [详细] 如何解决《节点/NPM/Grunt在jscs上失败(grunt-jscs)》经验,为你挑选了0个好方法。 ... [详细] 如何解决《如何使用纯函数可靠地将POSIXepoch秒转换为EST/EDT时间》经验,为你挑选了0个好方法。 ... [详细] 如何解决《如何使用BitBucketRESTapi2.0发布拉取请求评论?》经验,为你挑选了0个好方法。 ... [详细] 如何解决《jqueryanimate-返回原始位置》经验,为你挑选了1个好方法。 ... [详细] 如何解决《2列出字典问题》经验,为你挑选了1个好方法。 ... [详细] 如何解决《了解@weakify宏》经验,为你挑选了1个好方法。 ... [详细] 如何解决《在自定义JsonConverter的ReadJson方法中处理null对象》经验,为你挑选了1个好方法。 ... [详细] 如何解决《不区分大小写检查HttpServletRequest中的角色》经验,为你挑选了1个好方法。 ... [详细] 如何解决《如何不加选择地替换TOP1000行的选择列》经验,为你挑选了1个好方法。 ... [详细] 如何解决《WKWebView-Javascript确认和警报无法正常工作》经验,为你挑选了3个好方法。 ... [详细] 如何解决《Mediainstagram端点无法正常工作-媒体ID无效》经验,为你挑选了1个好方法。 ... [详细] 如何解决《如何让DockerGitlabCI运行器在其父主机上访问Git?》经验,为你挑选了1个好方法。 ... [详细] 如何解决《我们可以减少从ArrayList准备JavaHashSet的时间复杂度O(n)吗?》经验,为你挑选了1个好方法。 ... [详细] 吐了个 "CAO" !Tags | 热门标签RankList | 热门文章
- 1Golang结构数组值不附加In循环
- 2功能等同于带有变量比较的if表达式
- 3是否有一个函数来检查安装了devtools :: install_github的软件包是否已更新?
- 4仅在需要AngularJS时才注入模块依赖项(如插件)
- 5Ruby:定义自己的转换方法/协议
- 6如何在oracle中将日期转换为时间戳(DD-MON-YYYY HH24:MI:SS.FF格式)?
- 7如何在角度中使用npm模块?
- 8laravel / dingo API上的变压器用法
- 9Qt Android蓝牙套接字在Android 5.1.1和6.0上编写问题
- 10将currentCalendar()Date转换为NSCalendarIdentifierChinese
- 11子字符串:在字符串中获取"或"出现的索引
- 12将一列字符串转换为Pandas中的整数列
- 13iOS9:canOpenURL为WhatApp的url方案返回false
- 14在构建意图时,"这个"是指什么
- 15如果两者都有position:absolute,那么元素及其子元素的左值和顶值是什么?
- 16垂直对齐图像和文本在表中
- 17NestedScrollView在Recyclerview调整大小时滚动到顶部
- 18Caffe可以扩展到多个CPU核心吗?
- 19java.lang.OutOfMemoryError GC开销限制超过了Java堆空间?
- 20仅在php,mysql中显示前50个字符
DevBox开发工具箱 | 专业的在线开发工具网站 京公网安备 11010802040832号 | 京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有