为什么不使用HTML代码?

编程入门 行业动态 更新时间:2024-10-26 02:32:52
本文介绍了为什么不使用HTML代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

获得一个单击词的句子,如下面的链接所示。 jsfiddle/HKHGQ/129/ [ ^ ] 但是,当我将代码复制到html文件时,如下所示获取错误。不工作。

Hi, get the Sentence of a Clicked Word as in the below link. jsfiddle/HKHGQ/129/[^] but, when i copy the code to a html file as below getting error. not working.

<html> <head> <script src="jquery-1.8.3.js" language="javascript" type="text/javascript"></script> <script> function test() { $('p').each(function() { $(this).html($(this).text().split(/([\.\?!])(?= )/).map( function(v){return '<span class=sentence1>'+v+'</span>'} )); }); $('.sentence1').on('click', function() { //$('#result').text($(this).text()); }); } </script> </head> <body onload="test()"> <p>This is a test paragraph! I love cats. Dogs are fine too... Here's a number : 3.4. Please apply here</p> </body> </html>

错误来自以下代码的一部分。

the error getting at the below part of code.

$(this).html($(this).text().split(/([\.\?!])(?= )/).map( function(v){return '&lt;span class=sentence1&gt;'+v+'&lt;/span&gt;'} ));

错误:对象不支持此属性或方法

Error: Object doesn't support this property or method

推荐答案

(' p')。each( function (){ ('p').each(function() {

( this )。html(

( this )。text()。spli t(/([\.\?!])(?=)/)。map( function (v){返回 ' < span class = sentence1>' + v + ' < / span>'} )); }); (this).text().split(/([\.\?!])(?= )/).map( function(v){return '<span class=sentence1>'+v+'</span>'} )); });

更多推荐

为什么不使用HTML代码?

本文发布于:2023-11-25 03:10:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628079.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!