如何使用 JavaScript 从 li 中的输入获取值

如何获取值下拉列表 ul。显示控制台?

在此输入图像描述

// Profanity check  

$profaneReport = "";

$profanity_list = "hello TEN test commas";    

$allContent = "Hello, world! This is a senTENce for testing. It has more than TEN words and contains some punctuation,like commas.";


/* Create an array of all words in lowercase (for easier comparison) */

$profaneWords = explode( ' ', strtolower($profanity_list) );


/* Remove everything but a-z (i.e. all punctionation numbers etc.) from the sentence 

   We replace them with spaces, so we can break the sentence into words */

$alpha = preg_replace("/[^a-z0-9]+/", " ", strtolower($allContent));


/* Create an array of the words in the sentence */

$alphawords = explode( ' ', $alpha );


/* get all words that are in both arrays */

$wordsFoundInProfaneList = array_intersect ( $alphawords, $profaneWords);


// check if bad words were found, and display a message 

if ( !empty($wordsFoundInProfaneList)) {

    $profaneReportDesc = "Sorry, your content may contain such words as " . "<strong>" . implode( ", ", $wordsFoundInProfaneList) . '</strong>"';

} else {

    $profaneReportDesc = "Good: No profanity was found in your content";

}

echo $profaneReportDesc;


撒科打诨
浏览 99回答 1
1回答

慕桂英546537

您可以为输入设置 id 或 class,然后执行以下操作:&nbsp;var&nbsp;hidden=document.getElementsByClassName("input_class_name").value;或者&nbsp;var&nbsp;hidden=document.getElementsById("input_id").value;
打开App,查看更多内容
随时随地看视频慕课网APP