screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> </head> <body> <div id="app"></div> <script src="https://unpkg.com/react@17.0.2/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script> <script type="text/babel"> const { useState } = React; function App() { const originalString = "Example: Apple"; const parts = originalString.split(':'); // Check if there is a colon in the string if (parts.length === 2) { // The part after the colon is in parts[1] const afterColon = parts[1].trim(); return ( <div className='container'> <h2>React Js Get String After Colon(:)</h2> <p>Original String: {originalString}</p> <p>String After Colon: {afterColon}</p> </div> ); } else { // Handle the case where there is no colon in the string return ( <div className='no-colon'> Original String: {originalString}<br /> No colon found in the string. </div> ); } } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> /* Styles for the container class */ .container { width: 400px; border: 1px solid #ccc; padding: 10px; margin: 10px; border-radius: 5px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); margin: 0 auto } /* Styles for the no-colon class */ .no-colon { border: 1px solid #ff3333; padding: 10px; margin: 10px; border-radius: 5px; box-shadow: 0 0 5px rgba(255, 51, 51, 0.2); } </style> </body> </html>